JavaTM 2 Platform
Standard Ed. 6

类 java.util.concurrent.ThreadPoolExecutor
的使用

使用 ThreadPoolExecutor 的软件包
java.util.concurrent 在并发编程中很常用的实用工具类。 
 

java.util.concurrentThreadPoolExecutor 的使用
 

java.util.concurrentThreadPoolExecutor 的子类
 class ScheduledThreadPoolExecutor
          ThreadPoolExecutor,它可另行安排在给定的延迟后运行命令,或者定期执行命令。
 

参数类型为 ThreadPoolExecutorjava.util.concurrent 中的方法
 void RejectedExecutionHandler.rejectedExecution(Runnable r, ThreadPoolExecutor executor)
          当 execute 不能接受某个任务时,可以由 ThreadPoolExecutor 调用的方法。
 void ThreadPoolExecutor.CallerRunsPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e)
          执行调用者线程中的任务 r;如果执行程序已关闭,则会丢弃该任务。
 void ThreadPoolExecutor.AbortPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e)
          总是抛出 RejectedExecutionException。
 void ThreadPoolExecutor.DiscardPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e)
          不执行任何操作,在这种情况下将放弃任务 r。
 void ThreadPoolExecutor.DiscardOldestPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e)
          获取并忽略下一个任务,否则如果该任务立即可用,执行程序将执行该任务,然后再试图重新执行任务 r;如果执行程序已关闭,则会丢弃任务 r。
 


JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only