public class juc14 {
public static void main(String[] args) throws ExecutionException, InterruptedException {
//FutureTask实现了RunnableFuture,RunnableFuture继承了Runnable, Future
FutureTask task = new FutureTask<>(new call());
new Thread(task,"A").start();
Object o = task.get();
System.err.println(o);
}
}
class call implements Callable<String>{
@Override
public String call() throws Exception {
System.err.println("1024");
return "String";
}
}
如何使用Callable开启线程?(FutureTask)
最新推荐文章于 2024-04-07 11:47:05 发布