62,621
社区成员
发帖
与我相关
我的任务
分享
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class Test {
public Future<Void> future;
public void test() {
future = Executors.newSingleThreadExecutor().submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
//dosomething
return null;
}
});
try {
future.get();
//dosomething
} catch (Exception e) {
}
}
public static void main(String[] args) {
Test t=new Test();
t.test();
t.test();
t.test();
}
}