Class PoolableThread

java.lang.Object
java.lang.Thread
org.jini.rio.resources.resource.PoolableThread
All Implemented Interfaces:
Runnable

public final class PoolableThread extends Thread
An extension of Thread, PoolableThread instances know how to stay alive and wait in a pool
  • Field Details

    • nextThreadID

      protected static int nextThreadID
    • pool

      protected final ThreadPool pool
    • runObj

      protected Runnable runObj
      The runnable to run
  • Constructor Details

    • PoolableThread

      public PoolableThread(ThreadPool pool)
      A thread that is a good pool citizen.
  • Method Details

    • isReady

      public boolean isReady()
    • joinResource

      public void joinResource() throws InterruptedException
      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, use execute instead.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • execute

      public void execute(Runnable runnable) throws IllegalStateException
      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

      public Object getResource(Object key)
      Return the resource for the specified key
    • putResource

      public Object putResource(Object key, Object value)
      Return the resource for the specified key
    • clearResources

      public void clearResources()
      Clears the resource cache