com.notuvy.thread
Class ThreadControl

java.lang.Object
  extended by com.notuvy.thread.ThreadControl

public class ThreadControl
extends Object

Flags which control the operation of a worker thread. There is no actual functionality here. Rather, the implementation of the worker thread should properly use these flags to control its operation.

Author:
murali

Field Summary
protected static org.apache.log4j.Logger LOG
           
 
Constructor Summary
ThreadControl()
           
 
Method Summary
 boolean isAlive()
           
 boolean isEnabled()
           
 boolean isRunning()
          Is the thread engaged in actual work currently.
 void resume()
          Enable the worker to process any queued work.
protected  void setRunning(boolean pRunning)
          Called by the worker thread framework when actual work is started or finished.
 void stop()
          Terminate (permanently) the worker.
 void suspend()
          Temporarily disable the worker.
 String toString()
           
 void waitForQuiescence()
          If the worker has been stopped, wait for all outstanding work to finish.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.log4j.Logger LOG
Constructor Detail

ThreadControl

public ThreadControl()
Method Detail

isAlive

public boolean isAlive()

isEnabled

public boolean isEnabled()

isRunning

public boolean isRunning()
Is the thread engaged in actual work currently.

Returns:
boolean indicating that work is currently being performed.

setRunning

protected void setRunning(boolean pRunning)
Called by the worker thread framework when actual work is started or finished.

Parameters:
pRunning - Indication whether actual work is currently being performed.

toString

public String toString()
Overrides:
toString in class Object

stop

public void stop()
Terminate (permanently) the worker. Once the flag is marked "not alive", it can never again be marked "alive".


suspend

public void suspend()
Temporarily disable the worker. New work is allowed to be queued, but nothing will be acted on until resumed.


resume

public void resume()
Enable the worker to process any queued work.


waitForQuiescence

public void waitForQuiescence()
If the worker has been stopped, wait for all outstanding work to finish. New work will not be taken on, so upon exit of this method we know that the worker has been cleanly and fully shut down.



Copyright © 2013. All Rights Reserved.