Callable = Runable + return
Future: the future will produce the results of the implementation of storage
public static void main(String[] args) throws ExecutionException, InterruptedException {
Callable<String> callable = new Callable<String>() {
@Override
public String call() throws Exception {
return "Hello Callable!";
}
};
ExecutorService service = Executors.newCachedThreadPool();
Future<String> future = service.submit(callable);//submit方法 异步
System.out.println(future.get());//future.get()方法 阻塞
service.shutdown();
}