Java java.util.concurrent ThreadPoolExecutor fields, constructors, methods, implement or subclass

Example usage for Java java.util.concurrent ThreadPoolExecutor fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util.concurrent ThreadPoolExecutor.

The text is from its open source code.

Subclass

java.util.concurrent.ThreadPoolExecutor has subclasses.
Click this link to see all its subclasses.

Field

booleanallowCoreThreadTimeOut
If false (default), core threads stay alive even when idle.

Constructor

ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue)
Creates a new ThreadPoolExecutor with the given initial parameters, the default thread factory and the default rejected execution handler.
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory)
Creates a new ThreadPoolExecutor with the given initial parameters and ThreadPoolExecutor.AbortPolicy default rejected execution handler .
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, RejectedExecutionHandler handler)
Creates a new ThreadPoolExecutor with the given initial parameters and Executors#defaultThreadFactory default thread factory .
ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
Creates a new ThreadPoolExecutor with the given initial parameters.

Method

booleanawaitTermination(long timeout, TimeUnit unit)
voidexecute(Runnable command)
Executes the given task sometime in the future.
intgetActiveCount()
Returns the approximate number of threads that are actively executing tasks.
longgetCompletedTaskCount()
Returns the approximate total number of tasks that have completed execution.
intgetCorePoolSize()
Returns the core number of threads.
longgetKeepAliveTime(TimeUnit unit)
Returns the thread keep-alive time, which is the amount of time that threads may remain idle before being terminated.
intgetLargestPoolSize()
Returns the largest number of threads that have ever simultaneously been in the pool.
intgetMaximumPoolSize()
Returns the maximum allowed number of threads.
intgetPoolSize()
Returns the current number of threads in the pool.
BlockingQueuegetQueue()
Returns the task queue used by this executor.
longgetTaskCount()
Returns the approximate total number of tasks that have ever been scheduled for execution.
ThreadFactorygetThreadFactory()
Returns the thread factory used to create new threads.
List>invokeAll(Collection> tasks)
booleanisShutdown()
booleanisTerminated()
booleanisTerminating()
Returns true if this executor is in the process of terminating after #shutdown or #shutdownNow but has not completely terminated.
intprestartAllCoreThreads()
Starts all core threads, causing them to idly wait for work.
booleanprestartCoreThread()
Starts a core thread, causing it to idly wait for work.
voidpurge()
Tries to remove from the work queue all Future tasks that have been cancelled.
voidsetCorePoolSize(int corePoolSize)
Sets the core number of threads.
voidsetKeepAliveTime(long time, TimeUnit unit)
Sets the thread keep-alive time, which is the amount of time that threads may remain idle before being terminated.
voidsetMaximumPoolSize(int maximumPoolSize)
Sets the maximum allowed number of threads.
voidsetRejectedExecutionHandler(RejectedExecutionHandler handler)
Sets a new handler for unexecutable tasks.
voidsetThreadFactory(ThreadFactory threadFactory)
Sets the thread factory used to create new threads.
ListshutdownNow()
Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
Futuresubmit(Runnable task)
StringtoString()
Returns a string identifying this pool, as well as its state, including indications of run state and estimated worker and task counts.