public static void main(String[] args) throws InterruptedException, ExecutionException {
ExecutorService executorService=Executors.newSingleThreadExecutor();
Future<String> future=executorService.submit(new Callable(){
public String call() throws Exception {
Thread.sleep(3000);
return "Hello World!";
}
});
System.out.println("等待结果……");
System.out.println("得到结果:"+future.get());
executorService.shutdown();
}