package com.atguigu.bigdata.juc;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
/**
* @author tianmin
* @date 2020/3/2 0002
* @notes
*/
public class CallableTest {
public static void main(String[] args) throws ExecutionException, InterruptedException {
FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());
new Thread(futureTask, "A").start();
Integer result = futureTask.get();
System.out.println("结果:" + result);
}
}
class MyThread implements Callable<Integer>{
@Override
public Integer call() throws Exception {
System.out.println("*******come in call() method*****");
System.out.println(Thread.currentThread().getName());
return 1024;
}
}
来源:CSDN
作者:qq_37587652
链接:https://blog.csdn.net/qq_37587652/article/details/104620968