public static void main(String[] args) throws ExecutionException, InterruptedException {
ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(3, 3, 60L, TimeUnit.SECONDS, new LinkedBlockingDeque<>()); Callable callable = new Callable<String>() {
@Override public String call() throws Exception {
System.out.println(1); Thread.sleep(1000); return "2"; } };
Future<String> submit = poolExecutor.submit(callable);
String s = submit.get();//等线程执行完返回数据 System.out.println(s); }