org.apache.java.recycle.pool
Class Worker

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--org.apache.java.recycle.pool.Worker

class Worker
extends java.lang.Thread
implements Recyclable

This class extends the Thread class to add recyclable functionalities.

Version:
$Revision: 1.4 $ $Date: 1999/10/08 22:13:21 $

Field Summary
private  boolean alive
           
private  RecycleBin pool
           
private  Stoppable work
           
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritedAccessControlContext, initial_stack_memory, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, PrivateInfo, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadQ, values
 
Constructor Summary
protected Worker(java.lang.ThreadGroup group, RecycleBin pool, java.lang.String name)
          Allocates a new Worker object.
 
Method Summary
 void clean()
          Cleans this worker by setting its Work code to null.
 void destroy()
          Set the alive variable to false causing the worker to die.
protected  void execute(Stoppable work)
          Set the Work code this Worker must execute and notifies its thread to do it.
 void run()
          The main execution loop.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

work

private Stoppable work

pool

private RecycleBin pool

alive

private boolean alive
Constructor Detail

Worker

protected Worker(java.lang.ThreadGroup group,
                 RecycleBin pool,
                 java.lang.String name)
Allocates a new Worker object.
Method Detail

run

public final void run()
The main execution loop.
Overrides:
run in class java.lang.Thread

execute

protected void execute(Stoppable work)
Set the Work code this Worker must execute and notifies its thread to do it.

clean

public void clean()
Cleans this worker by setting its Work code to null.
Specified by:
clean in interface Recyclable

destroy

public void destroy()
Set the alive variable to false causing the worker to die. If the worker is stalled and a timeout generated this call, this method does not change the state of the worker (that must be destroyed in other ways).
Specified by:
destroy in interface Recyclable
Overrides:
destroy in class java.lang.Thread