首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ExecutorService接口的根本方法

2012-09-19 
ExecutorService接口的基本方法先来一段Exector,ExectorService接口的集成体系public interface Executor{

ExecutorService接口的基本方法

先来一段Exector,ExectorService接口的集成体系

public interface Executor{
??? void execute(Runnable command);
}

public interface ExectorService implements Executor{
??? void shutdown();

??? List<Runnable> shutdownNow();

??? boolean isShutdown();

??? boolean isTerminated();

?

? ? //
??? boolean awaitTermination(long timeout, TimeUnit unit)
??????? throws InterruptedException;

??? <T> Future<T> submit(Callable<T> task);

???
}



?


线程池Executor是异步的执行任务,因此任何时刻不能够直接获取提交的任务的状态。这些任务有可能已经完成,也有可能正在执行或者还在排队等待执行。因此关闭线程池可能出现一下几种情况:

平缓关闭(shutdown):已经启动的任务全部执行完毕,同时不再接受新的任务
立即关闭(shutdownNow):取消所有正在执行和未执行的任务


ExecutorService接口的根本方法

?

?

进入

?

?

awaitTermination(long?timeout, TimeUnit?unit)?

?

?

?

热点排行