org.objectweb.dream.control.activity.task.thread
Interface ThreadPoolController

All Known Implementing Classes:
ThreadPoolTask

public interface ThreadPoolController

Controller interface for thread pools. It allows increasing or decreasing the number of threads in the pool.


Field Summary
static long DEFAULT_WAIT_TIMEOUT
          The default timeout.
 
Method Summary
 void addThreads(int i)
          Adds threads in the pool.
 int getCapacity()
          Returns the capacity of the pool.
 int getNbActiveThreads()
          Returns the number of currently active threads.
 long getWaitTimeout()
          Returns the timeout while "dying" thread can be "reactivated".
 void removeThreads(int i)
          Removes threads from the pool.
 void setCapacity(int i)
          Sets the capacity of the pool.
 void setWaitTimeout(long millis)
          Sets the timeout while a "dying" thread can be "reactivated" and reused, rather than create a new thread.
 

Field Detail

DEFAULT_WAIT_TIMEOUT

public static final long DEFAULT_WAIT_TIMEOUT
The default timeout.

See Also:
setWaitTimeout(long), Constant Field Values
Method Detail

setCapacity

public void setCapacity(int i)
Sets the capacity of the pool. The capacity of the pool is the maximum number of currently executing threads. If the capacity is reduced, currently executing threads are not stopped. As a consequence, the number of executing threads may temporarily exceed the capacity.

Parameters:
i - the capacity of the pool.

getCapacity

public int getCapacity()
Returns the capacity of the pool.

Returns:
the capacity of the pool.

setWaitTimeout

public void setWaitTimeout(long millis)
Sets the timeout while a "dying" thread can be "reactivated" and reused, rather than create a new thread.

Parameters:
millis - timeout in millisecond.

getWaitTimeout

public long getWaitTimeout()
Returns the timeout while "dying" thread can be "reactivated".

Returns:
timeout in millisecond.

getNbActiveThreads

public int getNbActiveThreads()
Returns the number of currently active threads.

Returns:
the number of currently active threads.

addThreads

public void addThreads(int i)
                throws ThreadPoolOverflowException,
                       IllegalLifeCycleException
Adds threads in the pool. If the thread pool is stopping (see TaskLifeCycleController) the added threads are immediatly interrupted.

Parameters:
i - the number of thread to add.
Throws:
ThreadPoolOverflowException - if getNbActiveThread() + i > getCapacity()
IllegalLifeCycleException - if the component this interface belong has a lifecycle controller and is in the LifeCycleController.STOPPED state.

removeThreads

public void removeThreads(int i)
                   throws IllegalLifeCycleException
Removes threads from the pool. The threads are removed in a FIFO order. This method is not synchronized with the end of the removed threads. This means that the method may return before the end of the removed threads.

Parameters:
i - the number of thread to remove.
Throws:
IllegalLifeCycleException - if the component this interface belong has a lifecycle controller and is in the LifeCycleController.STOPPED state.


Copyright © 2003, 2004 - INRIA Rhone-Alpes - All Rights Reserved.