阅读背景:

如何停止java executor类中的所有可运行线程?

来源:互联网 
final ExecutorService executor = Executors.newFixedThreadPool(1);
final Future<?> future = executor.submit(myRunnable);
executor.shutdown();
if(executor.awaitTermination(10, TimeUnit.SECONDS)) {
  System.out.println("task completed");
}else{
  System.out.println("Executor is shutdown now");
}

//MyRunnable method is defined as task which I want to execute in a different thread.
final ExecutorService executor = Executors.newF



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: