Java Doc for ThreadPoolExecutor.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » concurrent » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.concurrent 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.util.concurrent.AbstractExecutorService
      java.util.concurrent.ThreadPoolExecutor

All known Subclasses:   java.util.concurrent.ScheduledThreadPoolExecutor,
ThreadPoolExecutor
public class ThreadPoolExecutor extends AbstractExecutorService (Code)

Inner Class :public static class CallerRunsPolicy implements RejectedExecutionHandler
Inner Class :public static class AbortPolicy implements RejectedExecutionHandler
Inner Class :public static class DiscardPolicy implements RejectedExecutionHandler
Inner Class :public static class DiscardOldestPolicy implements RejectedExecutionHandler


Constructor Summary
public  ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)
     Creates a new ThreadPoolExecutor with the given initial parameters and default thread factory and rejected execution handler. It may be more convenient to use one of the Executors factory methods instead of this general purpose constructor.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted.
public  ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
     Creates a new ThreadPoolExecutor with the given initial parameters and default rejected execution handler.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted.
public  ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)
     Creates a new ThreadPoolExecutor with the given initial parameters and default thread factory.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted.
public  ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
     Creates a new ThreadPoolExecutor with the given initial parameters.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted.

Method Summary
protected  voidafterExecute(Runnable r, Throwable t)
    
public  voidallowCoreThreadTimeOut(boolean value)
     Sets the policy governing whether core threads may time out and terminate if no tasks arrive within the keep-alive time, being replaced if needed when new tasks arrive.
public  booleanallowsCoreThreadTimeOut()
     Returns true if this pool allows core threads to time out and terminate if no tasks arrive within the keepAlive time, being replaced if needed when new tasks arrive.
public  booleanawaitTermination(long timeout, TimeUnit unit)
    
protected  voidbeforeExecute(Thread t, Runnable r)
     Method invoked prior to executing the given Runnable in the given thread.
public  voidexecute(Runnable command)
     Executes the given task sometime in the future.
protected  voidfinalize()
     Invokes shutdown when this executor is no longer referenced and it has no threads.
public  intgetActiveCount()
     Returns the approximate number of threads that are actively executing tasks.
public  longgetCompletedTaskCount()
     Returns the approximate total number of tasks that have completed execution.
public  intgetCorePoolSize()
     Returns the core number of threads.
public  longgetKeepAliveTime(TimeUnit unit)
     Returns the thread keep-alive time, which is the amount of time that threads in excess of the core pool size may remain idle before being terminated.
public  intgetLargestPoolSize()
     Returns the largest number of threads that have ever simultaneously been in the pool.
public  intgetMaximumPoolSize()
     Returns the maximum allowed number of threads.
public  intgetPoolSize()
     Returns the current number of threads in the pool.
public  BlockingQueue<Runnable>getQueue()
     Returns the task queue used by this executor.
public  RejectedExecutionHandlergetRejectedExecutionHandler()
     Returns the current handler for unexecutable tasks.
public  longgetTaskCount()
     Returns the approximate total number of tasks that have ever been scheduled for execution.
public  ThreadFactorygetThreadFactory()
     Returns the thread factory used to create new threads.
final  booleanisRunningOrShutdown(boolean shutdownOK)
     State check needed by ScheduledThreadPoolExecutor to enable running tasks during shutdown.
public  booleanisShutdown()
    
public  booleanisTerminated()
    
public  booleanisTerminating()
     Returns true if this executor is in the process of terminating after ThreadPoolExecutor.shutdown or ThreadPoolExecutor.shutdownNow but has not completely terminated.
 voidonShutdown()
     Performs any further cleanup following run state transition on invocation of shutdown.
public  intprestartAllCoreThreads()
     Starts all core threads, causing them to idly wait for work.
public  booleanprestartCoreThread()
     Starts a core thread, causing it to idly wait for work.
public  voidpurge()
     Tries to remove from the work queue all Future tasks that have been cancelled.
final  voidreject(Runnable command)
     Invokes the rejected execution handler for the given command.
public  booleanremove(Runnable task)
     Removes this task from the executor's internal queue if it is present, thus causing it not to be run if it has not already started.

This method may be useful as one part of a cancellation scheme.

final  voidrunWorker(Worker w)
     Main worker run loop.
public  voidsetCorePoolSize(int corePoolSize)
     Sets the core number of threads.
public  voidsetKeepAliveTime(long time, TimeUnit unit)
     Sets the time limit for which threads may remain idle before being terminated.
public  voidsetMaximumPoolSize(int maximumPoolSize)
     Sets the maximum allowed number of threads.
public  voidsetRejectedExecutionHandler(RejectedExecutionHandler handler)
     Sets a new handler for unexecutable tasks.
public  voidsetThreadFactory(ThreadFactory threadFactory)
     Sets the thread factory used to create new threads.
public  voidshutdown()
     Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
public  List<Runnable>shutdownNow()
     Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution.
protected  voidterminated()
     Method invoked when the Executor has terminated.
final  voidtryTerminate()
     Transitions to TERMINATED state if either (SHUTDOWN and pool and queue empty) or (STOP and pool empty).


Constructor Detail
ThreadPoolExecutor
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue)(Code)
Creates a new ThreadPoolExecutor with the given initial parameters and default thread factory and rejected execution handler. It may be more convenient to use one of the Executors factory methods instead of this general purpose constructor.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted. This queue will hold only the Runnable tasks submitted by the execute method.
throws:
  IllegalArgumentException - if one of the following holds:
corePoolSize < 0
keepAliveTime < 0
maximumPoolSize <= 0
maximumPoolSize < corePoolSize
throws:
  NullPointerException - if workQueue is null



ThreadPoolExecutor
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)(Code)
Creates a new ThreadPoolExecutor with the given initial parameters and default rejected execution handler.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted. This queue will hold only the Runnable tasks submitted by the execute method.
Parameters:
  threadFactory - the factory to use when the executorcreates a new thread
throws:
  IllegalArgumentException - if one of the following holds:
corePoolSize < 0
keepAliveTime < 0
maximumPoolSize <= 0
maximumPoolSize < corePoolSize
throws:
  NullPointerException - if workQueue or threadFactory is null



ThreadPoolExecutor
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler)(Code)
Creates a new ThreadPoolExecutor with the given initial parameters and default thread factory.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted. This queue will hold only the Runnable tasks submitted by the execute method.
Parameters:
  handler - the handler to use when execution is blockedbecause the thread bounds and queue capacities are reached
throws:
  IllegalArgumentException - if one of the following holds:
corePoolSize < 0
keepAliveTime < 0
maximumPoolSize <= 0
maximumPoolSize < corePoolSize
throws:
  NullPointerException - if workQueue or handler is null



ThreadPoolExecutor
public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)(Code)
Creates a new ThreadPoolExecutor with the given initial parameters.
Parameters:
  corePoolSize - the number of threads to keep in the pool, evenif they are idle, unless allowCoreThreadTimeOut is set
Parameters:
  maximumPoolSize - the maximum number of threads to allow in thepool
Parameters:
  keepAliveTime - when the number of threads is greater thanthe core, this is the maximum time that excess idle threadswill wait for new tasks before terminating.
Parameters:
  unit - the time unit for the keepAliveTime argument
Parameters:
  workQueue - the queue to use for holding tasks before they areexecuted. This queue will hold only the Runnable tasks submitted by the execute method.
Parameters:
  threadFactory - the factory to use when the executorcreates a new thread
Parameters:
  handler - the handler to use when execution is blockedbecause the thread bounds and queue capacities are reached
throws:
  IllegalArgumentException - if one of the following holds:
corePoolSize < 0
keepAliveTime < 0
maximumPoolSize <= 0
maximumPoolSize < corePoolSize
throws:
  NullPointerException - if workQueue or threadFactory or handler is null




Method Detail
afterExecute
protected void afterExecute(Runnable r, Throwable t)(Code)



allowCoreThreadTimeOut
public void allowCoreThreadTimeOut(boolean value)(Code)
Sets the policy governing whether core threads may time out and terminate if no tasks arrive within the keep-alive time, being replaced if needed when new tasks arrive. When false, core threads are never terminated due to lack of incoming tasks. When true, the same keep-alive policy applying to non-core threads applies also to core threads. To avoid continual thread replacement, the keep-alive time must be greater than zero when setting true . This method should in general be called before the pool is actively used.
Parameters:
  value - true if should time out, else false
throws:
  IllegalArgumentException - if value is true and the current keep-alive time is not greater than zero
since:
   1.6



allowsCoreThreadTimeOut
public boolean allowsCoreThreadTimeOut()(Code)
Returns true if this pool allows core threads to time out and terminate if no tasks arrive within the keepAlive time, being replaced if needed when new tasks arrive. When true, the same keep-alive policy applying to non-core threads applies also to core threads. When false (the default), core threads are never terminated due to lack of incoming tasks. true if core threads are allowed to time out,else false
since:
   1.6



awaitTermination
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException(Code)



beforeExecute
protected void beforeExecute(Thread t, Runnable r)(Code)
Method invoked prior to executing the given Runnable in the given thread. This method is invoked by thread t that will execute task r , and may be used to re-initialize ThreadLocals, or to perform logging.

This implementation does nothing, but may be customized in subclasses. Note: To properly nest multiple overridings, subclasses should generally invoke super.beforeExecute at the end of this method.
Parameters:
  t - the thread that will run task r
Parameters:
  r - the task that will be executed




execute
public void execute(Runnable command)(Code)
Executes the given task sometime in the future. The task may execute in a new thread or in an existing pooled thread. If the task cannot be submitted for execution, either because this executor has been shutdown or because its capacity has been reached, the task is handled by the current RejectedExecutionHandler .
Parameters:
  command - the task to execute
throws:
  RejectedExecutionException - at discretion of RejectedExecutionHandler , if the taskcannot be accepted for execution
throws:
  NullPointerException - if command is null



finalize
protected void finalize()(Code)
Invokes shutdown when this executor is no longer referenced and it has no threads.



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



getCompletedTaskCount
public long getCompletedTaskCount()(Code)
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. the number of tasks



getCorePoolSize
public int getCorePoolSize()(Code)
Returns the core number of threads. the core number of threads
See Also:   ThreadPoolExecutor.setCorePoolSize



getKeepAliveTime
public long getKeepAliveTime(TimeUnit unit)(Code)
Returns the thread keep-alive time, which is the amount of time that threads in excess of the core pool size may remain idle before being terminated.
Parameters:
  unit - the desired time unit of the result the time limit
See Also:   ThreadPoolExecutor.setKeepAliveTime



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



getMaximumPoolSize
public int getMaximumPoolSize()(Code)
Returns the maximum allowed number of threads. the maximum allowed number of threads
See Also:   ThreadPoolExecutor.setMaximumPoolSize



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



getQueue
public BlockingQueue<Runnable> getQueue()(Code)
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. the task queue



getRejectedExecutionHandler
public RejectedExecutionHandler getRejectedExecutionHandler()(Code)
Returns the current handler for unexecutable tasks. the current handler
See Also:   ThreadPoolExecutor.setRejectedExecutionHandler



getTaskCount
public long getTaskCount()(Code)
Returns the approximate total number of tasks that have ever been scheduled for execution. Because the states of tasks and threads may change dynamically during computation, the returned value is only an approximation. the number of tasks



getThreadFactory
public ThreadFactory getThreadFactory()(Code)
Returns the thread factory used to create new threads. the current thread factory
See Also:   ThreadPoolExecutor.setThreadFactory



isRunningOrShutdown
final boolean isRunningOrShutdown(boolean shutdownOK)(Code)
State check needed by ScheduledThreadPoolExecutor to enable running tasks during shutdown.
Parameters:
  shutdownOK - true if should return true if SHUTDOWN



isShutdown
public boolean isShutdown()(Code)



isTerminated
public boolean isTerminated()(Code)



isTerminating
public boolean isTerminating()(Code)
Returns true if this executor is in the process of terminating after ThreadPoolExecutor.shutdown or ThreadPoolExecutor.shutdownNow but has not completely terminated. This method may be useful for debugging. A return of true reported a sufficient period after shutdown may indicate that submitted tasks have ignored or suppressed interruption, causing this executor not to properly terminate. true if terminating but not yet terminated



onShutdown
void onShutdown()(Code)
Performs any further cleanup following run state transition on invocation of shutdown. A no-op here, but used by ScheduledThreadPoolExecutor to cancel delayed tasks.



prestartAllCoreThreads
public int prestartAllCoreThreads()(Code)
Starts all core threads, causing them to idly wait for work. This overrides the default policy of starting core threads only when new tasks are executed. the number of threads started



prestartCoreThread
public boolean prestartCoreThread()(Code)
Starts a core thread, causing it to idly wait for work. This overrides the default policy of starting core threads only when new tasks are executed. This method will return false if all core threads have already been started. true if a thread was started



purge
public void purge()(Code)
Tries to remove from the work queue all Future tasks that have been cancelled. This method can be useful as a storage reclamation operation, that has no other impact on functionality. Cancelled tasks are never executed, but may accumulate in work queues until worker threads can actively remove them. Invoking this method instead tries to remove them now. However, this method may fail to remove tasks in the presence of interference by other threads.



reject
final void reject(Runnable command)(Code)
Invokes the rejected execution handler for the given command. Package-protected for use by ScheduledThreadPoolExecutor.



remove
public boolean remove(Runnable task)(Code)
Removes this task from the executor's internal queue if it is present, thus causing it not to be run if it has not already started.

This method may be useful as one part of a cancellation scheme. It may fail to remove tasks that have been converted into other forms before being placed on the internal queue. For example, a task entered using submit might be converted into a form that maintains Future status. However, in such cases, method ThreadPoolExecutor.purge may be used to remove those Futures that have been cancelled.
Parameters:
  task - the task to remove true if the task was removed




runWorker
final void runWorker(Worker w)(Code)
Main worker run loop. Repeatedly gets tasks from queue and executes them, while coping with a number of issues: 1. We may start out with an initial task, in which case we don't need to get the first one. Otherwise, as long as pool is running, we get tasks from getTask. If it returns null then the worker exits due to changed pool state or configuration parameters. Other exits result from exception throws in external code, in which case completedAbruptly holds, which usually leads processWorkerExit to replace this thread. 2. Before running any task, the lock is acquired to prevent other pool interrupts while the task is executing, and clearInterruptsForTaskRun called to ensure that unless pool is stopping, this thread does not have its interrupt set. 3. Each task run is preceded by a call to beforeExecute, which might throw an exception, in which case we cause thread to die (breaking loop with completedAbruptly true) without processing the task. 4. Assuming beforeExecute completes normally, we run the task, gathering any of its thrown exceptions to send to afterExecute. We separately handle RuntimeException, Error (both of which the specs guarantee that we trap) and arbitrary Throwables. Because we cannot rethrow Throwables within Runnable.run, we wrap them within Errors on the way out (to the thread's UncaughtExceptionHandler). Any thrown exception also conservatively causes thread to die. 5. After task.run completes, we call afterExecute, which may also throw an exception, which will also cause thread to die. According to JLS Sec 14.20, this exception is the one that will be in effect even if task.run throws. The net effect of the exception mechanics is that afterExecute and the thread's UncaughtExceptionHandler have as accurate information as we can provide about any problems encountered by user code.
Parameters:
  w - the worker



setCorePoolSize
public void setCorePoolSize(int corePoolSize)(Code)
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 < 0
See Also:   ThreadPoolExecutor.getCorePoolSize



setKeepAliveTime
public void setKeepAliveTime(long time, TimeUnit unit)(Code)
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 causeexcess threads to terminate immediately after executing tasks.
Parameters:
  unit - the time unit of the time argument
throws:
  IllegalArgumentException - if time less than zero orif time is zero and allowsCoreThreadTimeOut
See Also:   ThreadPoolExecutor.getKeepAliveTime



setMaximumPoolSize
public void setMaximumPoolSize(int maximumPoolSize)(Code)
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 the new maximum isless than or equal to zero, orless than the
See Also:   ThreadPoolExecutor.getMaximumPoolSize



setRejectedExecutionHandler
public void setRejectedExecutionHandler(RejectedExecutionHandler handler)(Code)
Sets a new handler for unexecutable tasks.
Parameters:
  handler - the new handler
throws:
  NullPointerException - if handler is null
See Also:   ThreadPoolExecutor.getRejectedExecutionHandler



setThreadFactory
public void setThreadFactory(ThreadFactory threadFactory)(Code)
Sets the thread factory used to create new threads.
Parameters:
  threadFactory - the new thread factory
throws:
  NullPointerException - if threadFactory is null
See Also:   ThreadPoolExecutor.getThreadFactory



shutdown
public void shutdown()(Code)
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.
throws:
  SecurityException -



shutdownNow
public List<Runnable> shutdownNow()(Code)
Attempts to stop all actively executing tasks, halts the processing of waiting tasks, and returns a list of the tasks that were awaiting execution. These tasks are drained (removed) from the task queue upon return from this method.

There are no guarantees beyond best-effort attempts to stop processing actively executing tasks. This implementation cancels tasks via Thread.interrupt , so any task that fails to respond to interrupts may never terminate.
throws:
  SecurityException -




terminated
protected void terminated()(Code)
Method invoked when the Executor has terminated. Default implementation does nothing. Note: To properly nest multiple overridings, subclasses should generally invoke super.terminated within this method.



tryTerminate
final void tryTerminate()(Code)
Transitions to TERMINATED state if either (SHUTDOWN and pool and queue empty) or (STOP and pool empty). If otherwise eligible to terminate but workerCount is nonzero, interrupts an idle worker to ensure that shutdown signals propagate. This method must be called following any action that might make termination possible -- reducing worker count or removing tasks from the queue during shutdown. The method is non-private to allow access from ScheduledThreadPoolExecutor.



Methods inherited from java.util.concurrent.AbstractExecutorService
public List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException(Code)(Java Doc)
public List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException(Code)(Java Doc)
public T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException(Code)(Java Doc)
public T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException(Code)(Java Doc)
protected RunnableFuture<T> newTaskFor(Runnable runnable, T value)(Code)(Java Doc)
protected RunnableFuture<T> newTaskFor(Callable<T> callable)(Code)(Java Doc)
public Future submit(Runnable task)(Code)(Java Doc)
public Future<T> submit(Runnable task, T result)(Code)(Java Doc)
public Future<T> submit(Callable<T> task)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.