1.1 --- a/src/org/sonews/daemon/AbstractDaemon.java Sun Aug 29 17:28:58 2010 +0200
1.2 +++ b/src/org/sonews/daemon/AbstractDaemon.java Thu Jul 05 13:19:19 2012 +0200
1.3 @@ -32,70 +32,63 @@
1.4 public abstract class AbstractDaemon extends Thread
1.5 {
1.6
1.7 - /** This variable is write synchronized through setRunning */
1.8 - private boolean isRunning = false;
1.9 + /** This variable is write synchronized through setRunning */
1.10 + private boolean isRunning = false;
1.11
1.12 - /**
1.13 - * Protected constructor. Will be called by derived classes.
1.14 - */
1.15 - protected AbstractDaemon()
1.16 - {
1.17 - setDaemon(true); // VM will exit when all threads are daemons
1.18 - setName(getClass().getSimpleName());
1.19 - }
1.20 -
1.21 - /**
1.22 - * @return true if shutdown() was not yet called.
1.23 - */
1.24 - public boolean isRunning()
1.25 - {
1.26 - synchronized(this)
1.27 - {
1.28 - return this.isRunning;
1.29 - }
1.30 - }
1.31 -
1.32 - /**
1.33 - * Marks this thread to exit soon. Closes the associated JDBCDatabase connection
1.34 - * if available.
1.35 - * @throws java.sql.SQLException
1.36 - */
1.37 - public void shutdownNow()
1.38 - throws SQLException
1.39 - {
1.40 - synchronized(this)
1.41 - {
1.42 - this.isRunning = false;
1.43 - StorageManager.disableProvider();
1.44 - }
1.45 - }
1.46 -
1.47 - /**
1.48 - * Calls shutdownNow() but catches SQLExceptions if occurring.
1.49 - */
1.50 - public void shutdown()
1.51 - {
1.52 - try
1.53 - {
1.54 - shutdownNow();
1.55 - }
1.56 - catch(SQLException ex)
1.57 - {
1.58 - Log.get().warning(ex.toString());
1.59 - }
1.60 - }
1.61 -
1.62 - /**
1.63 - * Starts this daemon.
1.64 - */
1.65 - @Override
1.66 - public void start()
1.67 - {
1.68 - synchronized(this)
1.69 - {
1.70 - this.isRunning = true;
1.71 - }
1.72 - super.start();
1.73 - }
1.74 -
1.75 + /**
1.76 + * Protected constructor. Will be called by derived classes.
1.77 + */
1.78 + protected AbstractDaemon()
1.79 + {
1.80 + setDaemon(true); // VM will exit when all threads are daemons
1.81 + setName(getClass().getSimpleName());
1.82 + }
1.83 +
1.84 + /**
1.85 + * @return true if shutdown() was not yet called.
1.86 + */
1.87 + public boolean isRunning()
1.88 + {
1.89 + synchronized (this) {
1.90 + return this.isRunning;
1.91 + }
1.92 + }
1.93 +
1.94 + /**
1.95 + * Marks this thread to exit soon. Closes the associated JDBCDatabase connection
1.96 + * if available.
1.97 + * @throws java.sql.SQLException
1.98 + */
1.99 + public void shutdownNow()
1.100 + throws SQLException
1.101 + {
1.102 + synchronized (this) {
1.103 + this.isRunning = false;
1.104 + StorageManager.disableProvider();
1.105 + }
1.106 + }
1.107 +
1.108 + /**
1.109 + * Calls shutdownNow() but catches SQLExceptions if occurring.
1.110 + */
1.111 + public void shutdown()
1.112 + {
1.113 + try {
1.114 + shutdownNow();
1.115 + } catch (SQLException ex) {
1.116 + Log.get().warning(ex.toString());
1.117 + }
1.118 + }
1.119 +
1.120 + /**
1.121 + * Starts this daemon.
1.122 + */
1.123 + @Override
1.124 + public void start()
1.125 + {
1.126 + synchronized (this) {
1.127 + this.isRunning = true;
1.128 + }
1.129 + super.start();
1.130 + }
1.131 }