rudimentary java library beginning. cleaned up scripts quite
[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
9 import java.io.BufferedOutputStream;
10 import java.io.File;
11 import java.io.IOException;
12 import java.io.InputStreamReader;
13 import java.io.Reader;
14 import java.util.regex.Matcher;
15 import java.util.regex.Pattern;
16
17 import org.apache.commons.logging.Log;
18 import org.apache.commons.logging.LogFactory;
19
20 /**
21  * A simple java thread that hearkens back to the HOOPLE C++ ethread in features.
22  *
23  * @author Chris Koeritz
24  */
25 class ethread implements Runnable
26 {
27 //fix below to use better way to get class object.
28   private static Log c_logger = LogFactory.getLog(ethread.class);
29
30   private volatile Thread c_RealThread = null;
31
32   // the only variable on which both synchronize is the "thread finished" variable.
33   public ethread()
34   {
35   }
36
37   /**
38    * Begins execution of the thread.
39    */
40   public void start()
41   {
42     if( null == this.c_RealThread )
43     {
44       this.c_RealThread = new Thread(this);
45       this.c_RealThread.start();
46     }
47   }
48   
49   /**
50    * Stops execution of the thread, or at least attempts to.
51    */
52   public void stop()
53   {
54     Thread goAway = c_RealThread;
55     c_RealThread = null;
56     if (null != goAway) { goAway.interrupt(); }
57   }
58   
59   /**
60    * Returns true if the thread isn't null.
61    */
62   public boolean threadRunning()
63   {
64     return (null != this.c_RealThread);
65   }
66   
67   public void run()
68   {
69     if (false == threadRunning())
70     {
71       return; // stopped before it ever started
72     }
73     
74   }
75
76 }