1 package org.feistymeow.process;
3 import org.apache.commons.logging.Log;
4 import org.apache.commons.logging.LogFactory;
14 public abstract class ethread implements Runnable
16 private static Log c_logger = LogFactory.getLog(
ethread.class);
19 private volatile Thread c_RealThread =
null;
21 private volatile Object c_lock =
new Object();
23 private long c_period = 0;
25 private boolean c_stopThread =
false;
27 final long SNOOZE_PERIOD = 20;
58 synchronized (c_lock) {
59 if (
null == this.c_RealThread) {
60 this.c_RealThread =
new Thread(
this);
61 c_logger.debug(
"starting thread " + c_RealThread.getId());
62 this.c_RealThread.start();
77 }
catch (InterruptedException e) {
91 synchronized (c_lock) {
93 Thread goAway = c_RealThread;
106 synchronized (c_lock) {
107 return this.c_RealThread !=
null;
116 synchronized (c_lock) {
135 c_logger.debug(
"thread returned false, signifying it wants to exit. now dropping it.");
142 long nextRun = System.currentTimeMillis() + c_period;
143 while (System.currentTimeMillis() < nextRun) {
148 Thread.sleep(SNOOZE_PERIOD);
149 }
catch (InterruptedException e) {
154 }
catch (Throwable t) {
155 c_logger.info(
"exception thrown from performActivity: " + t.getLocalizedMessage(), t);
abstract boolean performActivity()