JXTA

net.jxta.instantp2p.util
Class WorkerThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--net.jxta.instantp2p.util.WorkerThread

public class WorkerThread
extends java.lang.Thread


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WorkerThread()
          Creates a new WorkerThread instance.
 
Method Summary
 void addData(java.lang.Runnable object)
          Adds data to the scheduler.
 boolean removeData(java.lang.Runnable object)
          Removes a Runnable object from the stack.
 void run()
          This method checks whether runObjects has any objects to process.
 void stopThread()
          Stops this thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkerThread

public WorkerThread()
Creates a new WorkerThread instance. This starts the new thread and the new thread waits until Runnable objects are placed into the work area via the method addData. If data are available, the run method of the Runnable instance is executed.
Method Detail

run

public void run()
This method checks whether runObjects has any objects to process. If so, the first object is processed. Otherwise, we wait until data becomes available
Overrides:
run in class java.lang.Thread

addData

public void addData(java.lang.Runnable object)
Adds data to the scheduler. The run method of the object passed in will be run, as soon as time is available
Parameters:
object - Runnable instance that needs to be executed

removeData

public boolean removeData(java.lang.Runnable object)
Removes a Runnable object from the stack. The runnable object will be removed if it exists on the stack. We return true if the object exists, false otherwise
Parameters:
object - Runnable instance to delete from the stack
Returns:
true if the Runnable object was deleted, false otherwise

stopThread

public void stopThread()
Stops this thread. There may be Runnable elements still in the queue, and depending on the current thread the first one may still finish running.

JXTA