CompletionService小记
CompletionService小记 在使用ExecutorService时,通过sumit执行一个Callable的时候,会立即返回一个异步任务结果,然后通过get获取异步任务结果的时候会阻塞,如下面这种情况,代码如下, import java.util.ArrayList; import java.util.List; 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; import java.util.concurrent.TimeUnit; /** * Created by xinxingegeya on 16/3/22. */ public class ExecutorServiceTest { public static void main(String args[]) throws ExecutionException, InterruptedException { ExecutorService