public static void testHelloworld() throws Exception {
ExecutorService threadPool= Executors.newFixedThreadPool(2);
Future future=threadPool.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
return 11;
}
});
//threadPool.shutdown();这里注释掉
System.out.println("++"+future.get());
System.out.println("--"+future.isCancelled());
System.out.println("==="+future.isDone());
}
public static void main(String[] args) throws Exception{
testHelloworld();
}
执行threadPool.shutdown()后。
如果注释掉System.out.println("++"+future.get()),System.out.println("==="+future.isDone());输出为false