net.jxta.search.util
Class ThreadService

java.lang.Object
  |
  +--net.jxta.search.util.ThreadService

public class ThreadService
extends java.lang.Object


Constructor Summary
ThreadService(int minThreadCount, int maxThreadCount, int threadIdleTimeout, boolean traceRunExceptions, boolean traceRunErrors)
           
 
Method Summary
 java.lang.Thread getAvailableThread(java.lang.Runnable target)
          Get an available thread.
 int getExistingThreads()
           
 int getMaxThreads()
           
 int getMinThreads()
           
 int getRunningThreads()
           
 java.lang.Thread getThread(java.lang.Runnable target)
          Blocking version of thread allocation.
 java.lang.Thread getThread(java.lang.Runnable target, long timeout)
          Get a thread from the pool to power the given target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadService

public ThreadService(int minThreadCount,
                     int maxThreadCount,
                     int threadIdleTimeout,
                     boolean traceRunExceptions,
                     boolean traceRunErrors)
Method Detail

getThread

public java.lang.Thread getThread(java.lang.Runnable target,
                                  long timeout)
                           throws java.lang.InterruptedException,
                                  java.lang.IllegalArgumentException
Get a thread from the pool to power the given target.
Parameters:
target - The target Runnable to run.
timeout - The number of milliseconds to wait for a thread to become available.
Throws:
java.lang.IllegalStateException - If the thread pool is shutting down.
See Also:
com.sun.jes.service.thread.ThreadService#getThread

getThread

public java.lang.Thread getThread(java.lang.Runnable target)
                           throws java.lang.InterruptedException
Blocking version of thread allocation.
Parameters:
target - The target object to run.
Returns:
A thread instance or null.
Throws:
java.lang.InterruptedException - If the caller is interrupted, or the thread service is uninstalled.

getAvailableThread

public java.lang.Thread getAvailableThread(java.lang.Runnable target)
                                    throws java.lang.InterruptedException
Get an available thread.
Returns:
A Thread, if one is available right away, or null .

getRunningThreads

public int getRunningThreads()

getExistingThreads

public int getExistingThreads()

getMaxThreads

public int getMaxThreads()

getMinThreads

public int getMinThreads()