package com.gavin.exer; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; public class CallableTest { static class Task1 implements Callable{ @Override public Boolean call() throws Exception { System.out.println(" Execute task 1"); return true; } } public static void main(String[] args) throws ExecutionException, InterruptedException { Callable task1 = new Task1(); ExecutorService executeService = Executors.newFixedThreadPool(1); Future future = executeService.submit(task1); System.out.println(future.get()); }}Copy the code