org.norther.tammi.core.thread
Interface PooledExecutor

All Superinterfaces:
Executor, ExecutorService, Startable, ThreadedExecutor
All Known Implementing Classes:
DefaultPooledExecutor

public interface PooledExecutor
extends ThreadedExecutor, Startable

An interface to executors that queue executables and run them when a pooled thread is available.

Author:
Ilkka Priha

Method Summary
 int getCorePoolSize()
          Gets the number of threads to cache (default = 0).
 long getKeepAliveTime()
          Gets the number of milliseconds to keep alive threads exceeding the number of core threads waiting for new commands.
 int getLargestPoolSize()
          Gets the largest number of active threads in the pool ever.
 int getMaxPoolSize()
          Gets the maximum number of threads to simultaneously execute.
 int getPoolSize()
          Gets the current number of active threads in the pool.
 int getQueueCapacity()
          Gets the queue capacity of the executor.
 RejectedExecutionHandler getRejectedExecutionHandler()
          Gets the rejected execution handler.
 int prestartAllCoreThreads()
          Creates and starts the core threads in the pool.
 boolean prestartCoreThread()
          Creates and starts a new core thread in the pool.
 void purge()
          Purges cancelled tasks from the queue.
 boolean remove(Runnable task)
          Removes the specified task.
 void setCorePoolSize(int size)
          Set the number of threads to cache.
 void setKeepAliveTime(long msecs)
          Sets the number of milliseconds to keep alive threads exceeding the number of core threads waiting for new commands.
 void setMaxPoolSize(int size)
          Sets the maximum number of threads to use.
 void setRejectedExecutionHandler(RejectedExecutionHandler handler)
          Sets the rejected execution handler.
 
Methods inherited from interface org.norther.tammi.core.thread.ThreadedExecutor
getThreadFactoryName, setThreadFactoryName
 
Methods inherited from interface org.norther.tammi.core.thread.Executor
getActiveCount, getCompletedTaskCount, getTaskCount
 
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
 
Methods inherited from interface java.util.concurrent.Executor
execute
 
Methods inherited from interface org.norther.tammi.core.base.Startable
isStarted, start, stop
 

Method Detail

getQueueCapacity

int getQueueCapacity()
Gets the queue capacity of the executor.

Returns:
the queue capacity.

getKeepAliveTime

long getKeepAliveTime()
Gets the number of milliseconds to keep alive threads exceeding the number of core threads waiting for new commands. A negative value means to wait forever. A zero value means not to wait at all.

Returns:
the keep alive time in msecs.

setKeepAliveTime

void setKeepAliveTime(long msecs)
Sets the number of milliseconds to keep alive threads exceeding the number of core threads waiting for new commands. A negative value means to wait forever. A zero value means not to wait at all.

Parameters:
msecs - the keep alive time in msecs.

getMaxPoolSize

int getMaxPoolSize()
Gets the maximum number of threads to simultaneously execute. New unqueued requests will be handled according to the current blocking policy once this limit is exceeded.

Returns:
the max pool size.

setMaxPoolSize

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

Parameters:
size - the max pool size or -1 for unlimited.
Throws:
IllegalArgumentException - if less or equal to zero.

getCorePoolSize

int getCorePoolSize()
Gets the number of threads to cache (default = 0).

Returns:
the core pool size.

setCorePoolSize

void setCorePoolSize(int size)
Set the number of threads to cache.

Parameters:
size - the core pool size.
Throws:
IllegalArgumentException - if less than zero.

getPoolSize

int getPoolSize()
Gets the current number of active threads in the pool. This number is just a snaphot, and may change immediately upon returning.

Returns:
the current pool size.

getLargestPoolSize

int getLargestPoolSize()
Gets the largest number of active threads in the pool ever.

Returns:
the largest pool size.

getRejectedExecutionHandler

RejectedExecutionHandler getRejectedExecutionHandler()
Gets the rejected execution handler.

Returns:
the handler to apply.

setRejectedExecutionHandler

void setRejectedExecutionHandler(RejectedExecutionHandler handler)
Sets the rejected execution handler.

Parameters:
handler - the handler to apply.

prestartCoreThread

boolean prestartCoreThread()
Creates and starts a new core thread in the pool.

Returns:
false if all already started, true otherwise.

prestartAllCoreThreads

int prestartAllCoreThreads()
Creates and starts the core threads in the pool. Return the number created.

Returns:
the number of created threads.

purge

void purge()
Purges cancelled tasks from the queue.


remove

boolean remove(Runnable task)
Removes the specified task.

Parameters:
task - the task.
Returns:
true if successful, false otherwise.


Copyright © 2004 The Norther Organization. All rights reserved.