Package org.jini.rio.resources.resource
Class PoolableThread
java.lang.Object
java.lang.Thread
org.jini.rio.resources.resource.PoolableThread
- All Implemented Interfaces:
Runnable
An extension of Thread, PoolableThread instances know how to stay alive and wait in a pool
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static intprotected final ThreadPoolprotected RunnableThe runnable to runFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSet a flag to stop this thread, after a run.voidClears the resource cachevoidDefine what to run, and wake up this dozing threadintgetID()Return my idgetResource(Object key) Return the resource for the specified keybooleanisReady()voidWaits for the resource to completeputResource(Object key, Object value) Return the resource for the specified keyfinal voidrun()Wait in the pool, until someone needs this thread, then reenter pool.voidStop the thread's execution by interrupting it without marking the flag as not aliveMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Field Details
-
nextThreadID
protected static int nextThreadID -
pool
-
runObj
The runnable to run
-
-
Constructor Details
-
PoolableThread
A thread that is a good pool citizen.
-
-
Method Details
-
isReady
public boolean isReady() -
joinResource
Waits for the resource to complete- Throws:
InterruptedException
-
run
public final void run()Wait in the pool, until someone needs this thread, then reenter pool. Do not override this method, useexecuteinstead. -
execute
Define what to run, and wake up this dozing thread- Throws:
IllegalStateException
-
cleanStop
public void cleanStop()Set a flag to stop this thread, after a run. -
stopExecution
public void stopExecution()Stop the thread's execution by interrupting it without marking the flag as not alive -
getID
public int getID()Return my id -
getResource
Return the resource for the specified key -
putResource
Return the resource for the specified key -
clearResources
public void clearResources()Clears the resource cache
-