com.rhi.architecture.threads
Class WorkerThread

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.rhi.architecture.threads.WorkerThread
All Implemented Interfaces:
java.lang.Runnable

public class WorkerThread
extends java.lang.Thread

Worker Threads performs a given work and sleeps after the work is finished. The thread is managed by a ThreadPool and is used in conjuction with a ThreadPool. The threads sleeps as long as there is no work to be performed. ThreadPool assigns work to the thread and wakes up the WorkerThread to perform the given work. Once the thread finishes the work it sets itself to as having no work.

Version:
1.0
Author:
Chandra Ilindra

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
WorkerThread(ThreadPool pool)
          Constructor - constructs a WorkerThread
 
Method Summary
 void markForShutDown()
          mark the thread to be shutdown.
 boolean noWork()
          return true is there is no work to be performed.
 void run()
          Perform the following steps, in a loop, until asked to shutdown: 1.
 void setNoWork()
          assign no work to the worked thread.
 void setWork(java.lang.Runnable action)
          Sets the work to be performed by the thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, 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(ThreadPool pool)
Constructor - constructs a WorkerThread

Parameters:
pool - - reference to the managing ThreadPool
Since:
1.0
Method Detail

run

public void run()
Perform the following steps, in a loop, until asked to shutdown: 1. If there is no work then go to sleep ( wait ). 2. If there is work: - perform the work - reset work to null 3. Exit the loop, if asked to shutdown.

Since:
1.0

noWork

public boolean noWork()
return true is there is no work to be performed.

Returns:
boolean
Since:
1.0

setNoWork

public void setNoWork()
assign no work to the worked thread.

Since:
1.0

markForShutDown

public void markForShutDown()
mark the thread to be shutdown.

Since:
1.0

setWork

public void setWork(java.lang.Runnable action)
Sets the work to be performed by the thread.

Parameters:
action - - action to be performed by the thread
Since:
1.0


Copyright © 2002-2004 Robert Half International. All Rights Reserved.