class TestCall implements Callable {
@Override
public Object call() {
System.out.println(Thread.currentThread().getName() + "打印");
return "返回数据";
}
}
public class Test_callable {
public static void main(String[] args) throws ExecutionException, InterruptedException {
TestCall call = new TestCall();
FutureTask<String> futureTask = new FutureTask(call);
Thread thread = new Thread(futureTask);
thread.start();
String s = futureTask.get();
System.out.println(s);
}
}