org.exoplatform.services.threadpool.impl
Class ThreadPoolServiceImpl

java.lang.Object
  extended by org.exoplatform.services.threadpool.impl.ThreadPoolServiceImpl
All Implemented Interfaces:
ThreadPoolService

Deprecated.

@Deprecated
public class ThreadPoolServiceImpl
extends Object
implements ThreadPoolService


Nested Class Summary
protected static interface ThreadPoolServiceImpl.BlockedExecutionStrategy
          Deprecated. Class for actions to take when execute() blocks.
protected  class ThreadPoolServiceImpl.DiscardWhenBlocked
          Deprecated. Class defining Discard action *
protected  class ThreadPoolServiceImpl.RunWhenBlocked
          Deprecated. Class defining Run action *
protected  class ThreadPoolServiceImpl.WaitWhenBlocked
          Deprecated. Class defining Wait action *
protected  class ThreadPoolServiceImpl.Worker
          Deprecated. Class defining the basic run loop for pooled threads.
 
Field Summary
protected  ThreadPoolServiceImpl.BlockedExecutionStrategy blockedExecutionStrategy
          Deprecated. The current strategy *
static long DEFAULT_MAXIDLETIME
          Deprecated. The maximum time to keep worker threads alive waiting for new tasks; used if not otherwise specified.
static int DEFAULT_MAXIMUMPOOLSIZE
          Deprecated. The maximum pool size; used if not otherwise specified.
static int DEFAULT_NORMALPOOLSIZE
          Deprecated. The normal pool size; used if not otherwise specified.
protected  Queue handOff
          Deprecated.  
protected  long maxIdleTime
          Deprecated.  
protected  int maximumPoolSize
          Deprecated.  
protected  int normalPoolSize
          Deprecated.  
protected  Object poolLock
          Deprecated. Lock used for protecting poolSize and threads map *
protected  int poolSize
          Deprecated. Current pool size.
protected  Map threads
          Deprecated. An object to map active worker objects to their active thread.
 
Constructor Summary
ThreadPoolServiceImpl(LogService logService)
          Deprecated. Construct a new pool with all default settings
 
Method Summary
protected  void addThread(Runnable task)
          Deprecated. Create and start a thread to handle a new task.
 int createThreads(int numberOfThreads)
          Deprecated. Create and start up to numberOfThreads threads in the pool.
 void discardWhenBlocked()
          Deprecated. Set the policy for blocked execution to be to return without executing the request
 List drain()
          Deprecated. Remove all unprocessed tasks from pool queue, and return them in a java.util.List.
 void execute(Runnable task)
          Deprecated. Arrange for the given task to be executed by a thread in this pool.
protected  ThreadPoolServiceImpl.BlockedExecutionStrategy getBlockedExecutionStrategy()
          Deprecated. Get the strategy for blocked execution *
 long getMaxIdleTime()
          Deprecated. Return the number of milliseconds to keep threads alive waiting for new tasks.
 int getMaximumPoolSize()
          Deprecated. Return the maximum number of threads to simultaneously execute New requests are handled according to the current blocking policy once this limit is exceeded.
 int getNormalPoolSize()
          Deprecated. Return the normal number of threads to simultaneously execute.
 int getPoolSize()
          Deprecated. Return the current number of active threads in the pool.
protected  Runnable getTask()
          Deprecated. get a task from the handoff queue *
protected  ThreadFactoryIF getThreadFactory()
          Deprecated. Return the current thread factory object.
 void interruptAll()
          Deprecated. Interrupt all threads in the pool, causing them all to terminate.
 void runWhenBlocked()
          Deprecated. Set the policy for blocked execution to be that the current thread executes the task if there are no available threads in the pool.
 void setMaxIdleTime(long msecs)
          Deprecated. Set the number of milliseconds to keep threads alive waiting for new tasks.
 void setMaximumPoolSize(int newMaximum)
          Deprecated. Set the maximum number of threads to use.
 void setNormalPoolSize(int newNormal)
          Deprecated. Set the normal number of threads to use.
 void setThreadFactory(ThreadFactoryIF newValue)
          Deprecated. Set the object that will be used to create threads.
 void WhenBlocked()
          Deprecated. Set the policy for blocked execution to be to wait until a thread is available.
protected  void workerDone(ThreadPoolServiceImpl.Worker w)
          Deprecated. Called upon termination of worker thread *
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAXIMUMPOOLSIZE

public static final int DEFAULT_MAXIMUMPOOLSIZE
Deprecated. 
The maximum pool size; used if not otherwise specified. Default value is 500

See Also:
Constant Field Values

DEFAULT_NORMALPOOLSIZE

public static final int DEFAULT_NORMALPOOLSIZE
Deprecated. 
The normal pool size; used if not otherwise specified. Default value is 1.

See Also:
Constant Field Values

DEFAULT_MAXIDLETIME

public static final long DEFAULT_MAXIDLETIME
Deprecated. 
The maximum time to keep worker threads alive waiting for new tasks; used if not otherwise specified. Default value is one minute (60000 milliseconds).

See Also:
Constant Field Values

maximumPoolSize

protected volatile int maximumPoolSize
Deprecated. 

normalPoolSize

protected volatile int normalPoolSize
Deprecated. 

maxIdleTime

protected long maxIdleTime
Deprecated. 

handOff

protected Queue handOff
Deprecated. 

poolLock

protected Object poolLock
Deprecated. 
Lock used for protecting poolSize and threads map *


poolSize

protected volatile int poolSize
Deprecated. 
Current pool size. Relies on poolLock for all locking. But is also volatile to allow simpler checking inside worker thread runloop.


threads

protected Map threads
Deprecated. 
An object to map active worker objects to their active thread. This is used by the interruptAll method. It may also be useful in subclasses that need to perform other thread management chores. All operations on the Map should be done holding a synchronization lock on poolLock.


blockedExecutionStrategy

protected ThreadPoolServiceImpl.BlockedExecutionStrategy blockedExecutionStrategy
Deprecated. 
The current strategy *

Constructor Detail

ThreadPoolServiceImpl

public ThreadPoolServiceImpl(LogService logService)
Deprecated. 
Construct a new pool with all default settings

Method Detail

getMaximumPoolSize

public int getMaximumPoolSize()
Deprecated. 
Return the maximum number of threads to simultaneously execute New requests are handled according to the current blocking policy once this limit is exceeded.


setMaximumPoolSize

public void setMaximumPoolSize(int newMaximum)
Deprecated. 
Set the maximum number of threads to use. Decreasing the pool size will not immediately kill existing threads, but they may later die when idle.

Throws:
IllegalArgumentException - if less or equal to zero. (It is not considered an error to set the maximum to be less than than the normal. However, in this case there are no guarantees about behavior.)

getNormalPoolSize

public int getNormalPoolSize()
Deprecated. 
Return the normal number of threads to simultaneously execute. (Default value is 1). If fewer than the mininum number are running upon reception of a new request, a new thread is started to handle this request.


setNormalPoolSize

public void setNormalPoolSize(int newNormal)
Deprecated. 
Set the normal number of threads to use.

Throws:
IllegalArgumentException - if less than zero. (It is not considered an error to set the normal to be greater than the maximum. However, in this case there are no guarantees about behavior.)

getPoolSize

public int getPoolSize()
Deprecated. 
Return the current number of active threads in the pool. This number is just a snaphot, and may change immediately.


setThreadFactory

public void setThreadFactory(ThreadFactoryIF newValue)
Deprecated. 
Set the object that will be used to create threads.


getThreadFactory

protected ThreadFactoryIF getThreadFactory()
Deprecated. 
Return the current thread factory object.


addThread

protected void addThread(Runnable task)
Deprecated. 
Create and start a thread to handle a new task. Call only when holding poolLock.


createThreads

public int createThreads(int numberOfThreads)
Deprecated. 
Create and start up to numberOfThreads threads in the pool.

Returns:
The actual number of threads created. This may be less than the number of threads requested if creating more would exceed maximum pool size.

interruptAll

public void interruptAll()
Deprecated. 
Interrupt all threads in the pool, causing them all to terminate. Threads will terminate sooner if the executed tasks themselves respond to interrupts.


drain

public List drain()
Deprecated. 
Remove all unprocessed tasks from pool queue, and return them in a java.util.List. It should normally be used only when there are not any active clients of the pool (otherwise you face the possibility that the method will loop pulling out tasks as clients are putting them in.) This method can be useful after shutting down a pool (via interruptAll) to determine whether there are any pending tasks that were not processed. You can then, for example execute all unprocessed tasks via code along the lines of:
 List tasks = pool.drain();
 for (Iterator it = tasks.iterator(); it.hasNext();)
   ((Runnable) (it.next())).run();
 


getMaxIdleTime

public long getMaxIdleTime()
Deprecated. 
Return the number of milliseconds to keep threads alive waiting for new tasks. A negative value means to wait forever. A zero value means not to wait at all.


setMaxIdleTime

public void setMaxIdleTime(long msecs)
Deprecated. 
Set the number of milliseconds to keep threads alive waiting for new tasks. A negative value means to wait forever. A zero value means not to wait at all.


workerDone

protected void workerDone(ThreadPoolServiceImpl.Worker w)
Deprecated. 
Called upon termination of worker thread *


getTask

protected Runnable getTask()
                    throws InterruptedException
Deprecated. 
get a task from the handoff queue *

Throws:
InterruptedException

getBlockedExecutionStrategy

protected ThreadPoolServiceImpl.BlockedExecutionStrategy getBlockedExecutionStrategy()
Deprecated. 
Get the strategy for blocked execution *


runWhenBlocked

public void runWhenBlocked()
Deprecated. 
Set the policy for blocked execution to be that the current thread executes the task if there are no available threads in the pool.


WhenBlocked

public void WhenBlocked()
Deprecated. 
Set the policy for blocked execution to be to wait until a thread is available.


discardWhenBlocked

public void discardWhenBlocked()
Deprecated. 
Set the policy for blocked execution to be to return without executing the request


execute

public void execute(Runnable task)
             throws InterruptedException
Deprecated. 
Arrange for the given task to be executed by a thread in this pool. The method normally returns when the task has been handed off for (possibly later) execution.

Specified by:
execute in interface ThreadPoolService
Throws:
InterruptedException


Copyright © 2009 eXo Platform SAS. All Rights Reserved.