perform activity must be public, duhhh.
[feisty_meow.git] / kona / src / org / feistymeow / process / ethread.java
index 6bd87ad726ddac183676f606fa84f2bdaa96eb76..73e2acd7247b6c863f984b153a065bdaa6358709 100644 (file)
@@ -51,7 +51,7 @@ public abstract class ethread implements Runnable
         * shot threads executed via runOnce, but matters for the periodic threads started with
         * runPeriodic.
         */
-       abstract boolean performActivity();
+       abstract public boolean performActivity();
 
        /**
         * Begins execution of the thread.
@@ -74,7 +74,7 @@ public abstract class ethread implements Runnable
        {
                cancel();
                while (true) {
-                       if (threadRunning()) {
+                       if (threadAlive()) {
                                try {
                                        Thread.sleep(40);
                                } catch (InterruptedException e) {
@@ -102,9 +102,9 @@ public abstract class ethread implements Runnable
        }
 
        /**
-        * Returns true if the thread isn't null.
+        * Returns true if the thread object is still alive.  this does not necessarily mean it is currently active.
         */
-       public boolean threadRunning()
+       public boolean threadAlive()
        {
                synchronized (c_lock) {
                        return this.c_RealThread != null;
@@ -128,35 +128,33 @@ public abstract class ethread implements Runnable
        @Override
        public void run()
        {
-                       if (!threadRunning()) {
-                               return; // stopped before it ever started. how can this be? we just got invoked.
-                       }
-                       try {
-                               while (true) {
-                                       boolean keepGoing = performActivity();
-                                       if (!keepGoing) {
-                                               c_logger.debug("thread returned false for single shot thread.  just saying.");
-                                       }
-                                       if (c_period == 0) {
-                                               // not a periodic thread, so we're done now.
+               if (!threadAlive()) {
+                       return; // stopped before it ever started. how can this be? we just got invoked.
+               }
+               try {
+                       while (true) {
+                               boolean keepGoing = performActivity();
+                               if (!keepGoing) {
+                                       c_logger.debug("thread returned false for single shot thread.  just saying.");
+                               }
+                               if (c_period == 0) {
+                                       // not a periodic thread, so we're done now.
+                                       break;
+                               }
+                               long nextRun = System.currentTimeMillis() + c_period;
+                               while (System.currentTimeMillis() < nextRun) {
+                                       if (shouldStop()) {
                                                break;
                                        }
-                                       long nextRun = System.currentTimeMillis() + c_period;
-                                       while (System.currentTimeMillis() < nextRun) {
-                                               if (shouldStop()) {
-                                                       break;
-                                               }
-                                               try {
-                                                       Thread.sleep(SNOOZE_PERIOD);
-                                               } catch (InterruptedException e) {
-                                                       // well, we'll hit it again soon.
-                                               }
+                                       try {
+                                               Thread.sleep(SNOOZE_PERIOD);
+                                       } catch (InterruptedException e) {
+                                               // well, we'll hit it again soon.
                                        }
                                }
-                       } catch (Throwable t) {
-                               c_logger.info("exception thrown from performActivity: " + t.getLocalizedMessage(), t);
                        }
+               } catch (Throwable t) {
+                       c_logger.info("exception thrown from performActivity: " + t.getLocalizedMessage(), t);
                }
-       
+       }
 }
-