com.sun.grizzly.util
Interface ExtendedThreadPool

All Superinterfaces:
Executor, ExecutorService
All Known Implementing Classes:
AbstractThreadPool, DefaultThreadPool, FixedThreadPool, GrizzlyExecutorService, StatsThreadPool, SyncThreadPool

public interface ExtendedThreadPool
extends ExecutorService

Thread pool, from which it's possible to gather statistics information, and finer control its execution.

Author:
Alexey Stashok

Method Summary
 int getActiveCount()
          Returns the approximate number of threads that are actively executing tasks.
 long getCompletedTaskCount()
          Returns the approximate total number of tasks that have completed execution.
 int getCorePoolSize()
          Returns the core number of threads.
 long getKeepAliveTime(TimeUnit unit)
          Returns the thread keep-alive time, which is the amount of time which threads in excess of the core pool size may remain idle before being terminated.
 int getLargestPoolSize()
          Returns the largest number of threads that have ever simultaneously been in the pool.
 int getMaximumPoolSize()
          Returns the maximum allowed number of threads.
 int getMaxQueuedTasksCount()
           
 String getName()
           
 int getPoolSize()
          Returns the current number of threads in the pool.
 int getPriority()
           
 Queue<Runnable> getQueue()
          Returns the task queue used by this executor.
 int getQueueSize()
          Returns the number of tasks, which are currently waiting in the queue.
 int getTaskCount()
          Returns the approximate total number of tasks that have been scheduled for execution.
 ThreadFactory getThreadFactory()
          Returns the thread factory used to create new threads.
 void setCorePoolSize(int corePoolSize)
          Sets the core number of threads.
 void setKeepAliveTime(long time, TimeUnit unit)
          Sets the time limit for which threads may remain idle before being terminated.
 void setMaximumPoolSize(int maximumPoolSize)
          Sets the maximum allowed number of threads.
 void setMaxQueuedTasksCount(int maxTasksCount)
           
 void setName(String name)
           
 void setPriority(int priority)
           
 void setThreadFactory(ThreadFactory threadFactory)
          Sets the thread factory used to create new threads.
 
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
 

Method Detail

getActiveCount

int getActiveCount()
Returns the approximate number of threads that are actively executing tasks.

Returns:
the number of threads

getTaskCount

int getTaskCount()
Returns the approximate total number of tasks that have been scheduled for execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

Returns:
the number of tasks

getCompletedTaskCount

long getCompletedTaskCount()
Returns the approximate total number of tasks that have completed execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation, but one that does not ever decrease across successive calls.

Returns:
the number of tasks

getCorePoolSize

int getCorePoolSize()
Returns the core number of threads.

Returns:
the core number of threads
See Also:
setCorePoolSize(int)

setCorePoolSize

void setCorePoolSize(int corePoolSize)
Sets the core number of threads. This overrides any value set in the constructor. If the new value is smaller than the current value, excess existing threads will be terminated when they next become idle. If larger, new threads will, if needed, be started to execute any queued tasks.

Parameters:
corePoolSize - the new core size
Throws:
IllegalArgumentException - if corePoolSize less than zero
See Also:
getCorePoolSize()

getLargestPoolSize

int getLargestPoolSize()
Returns the largest number of threads that have ever simultaneously been in the pool.

Returns:
the number of threads

getPoolSize

int getPoolSize()
Returns the current number of threads in the pool.

Returns:
the number of threads

getQueue

Queue<Runnable> getQueue()
Returns the task queue used by this executor. Access to the task queue is intended primarily for debugging and monitoring. This queue may be in active use. Retrieving the task queue does not prevent queued tasks from executing.

Returns:
the task queue

getQueueSize

int getQueueSize()
Returns the number of tasks, which are currently waiting in the queue.

Returns:
the number of tasks, which are currently waiting in the queue.

getKeepAliveTime

long getKeepAliveTime(TimeUnit unit)
Returns the thread keep-alive time, which is the amount of time which threads in excess of the core pool size may remain idle before being terminated.

Parameters:
unit - the desired time unit of the result
Returns:
the time limit
See Also:
setKeepAliveTime(long, java.util.concurrent.TimeUnit)

setKeepAliveTime

void setKeepAliveTime(long time,
                      TimeUnit unit)
Sets the time limit for which threads may remain idle before being terminated. If there are more than the core number of threads currently in the pool, after waiting this amount of time without processing a task, excess threads will be terminated. This overrides any value set in the constructor.

Parameters:
time - the time to wait. A time value of zero will cause excess threads to terminate immediately after executing tasks.
unit - the time unit of the time argument
Throws:
IllegalArgumentException - if time less than zero
See Also:
getKeepAliveTime(java.util.concurrent.TimeUnit)

getMaximumPoolSize

int getMaximumPoolSize()
Returns the maximum allowed number of threads.

Returns:
the maximum allowed number of threads
See Also:
setMaximumPoolSize(int)

setMaximumPoolSize

void setMaximumPoolSize(int maximumPoolSize)
Sets the maximum allowed number of threads. This overrides any value set in the constructor. If the new value is smaller than the current value, excess existing threads will be terminated when they next become idle.

Parameters:
maximumPoolSize - the new maximum
Throws:
IllegalArgumentException - if maximumPoolSize less than zero or the core pool size
See Also:
getMaximumPoolSize()

getMaxQueuedTasksCount

int getMaxQueuedTasksCount()

setMaxQueuedTasksCount

void setMaxQueuedTasksCount(int maxTasksCount)
Parameters:
maxTasksCount -

getPriority

int getPriority()

setPriority

void setPriority(int priority)

getName

String getName()

setName

void setName(String name)
Parameters:
name -

setThreadFactory

void setThreadFactory(ThreadFactory threadFactory)
Sets the thread factory used to create new threads.

Parameters:
threadFactory - the new thread factory
Throws:
NullPointerException - if threadFactory is null
See Also:
getThreadFactory()

getThreadFactory

ThreadFactory getThreadFactory()
Returns the thread factory used to create new threads.

Returns:
the current thread factory
See Also:
setThreadFactory(java.util.concurrent.ThreadFactory)


Copyright © 2013 Oracle Corporation. All Rights Reserved.