280a08305dd39d9495022ec86835c3b8155a1e06
[feisty_meow.git] / kona / src / org / feistymeow / process / ethread.java
1
2 package org.feistymeow.process;
3
4 //still in progress...
5 // not compilable yet probably, 
6 // plus missing the timed features of ethread.
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 /**
12  * A simple java thread that hearkens back to the HOOPLE C++ ethread in features.
13  *
14  * @author Chris Koeritz
15  */
16 class ethread implements Runnable
17 {
18 //fix below to use better way to get class object.
19   private static Log c_logger = LogFactory.getLog(ethread.class);
20
21   private volatile Thread c_RealThread = null;
22
23   // the only variable on which both synchronize is the "thread finished" variable.
24   public ethread()
25   {
26           c_logger.warn("this class needs to be implemented and used in an example.");
27   }
28
29   /**
30    * Begins execution of the thread.
31    */
32   public void start()
33   {
34     if( null == this.c_RealThread )
35     {
36       this.c_RealThread = new Thread(this);
37       this.c_RealThread.start();
38     }
39   }
40   
41   /**
42    * Stops execution of the thread, or at least attempts to.
43    */
44   public void stop()
45   {
46     Thread goAway = c_RealThread;
47     c_RealThread = null;
48     if (null != goAway) { goAway.interrupt(); }
49   }
50   
51   /**
52    * Returns true if the thread isn't null.
53    */
54   public boolean threadRunning()
55   {
56     return (null != this.c_RealThread);
57   }
58   
59   public void run()
60   {
61     if (false == threadRunning())
62     {
63       return; // stopped before it ever started
64     }
65     
66   }
67
68 }