package com.concurrent.task;

import java.util.concurrent.*;

/**
 * <p/>
 * User : krisibm@163.com
 * Date: 2015/9/22
 * Time: 10:50
 */
public class CallableFutureResult {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newCachedThreadPool();
        Task task = new Task();

        Future<Integer> future = executorService.submit(task);

        executorService.shutdown();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("主线程在执行任务");

        try {
            Integer result = future.get();
            System.out.println("task execute result is : " + result);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }

}


@@ -51,17 +51,154 @@
 current.
-*
+ExecutionException;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.Future
 ;%0A%0A/**%0A 
@@ -346,24 +346,25 @@
 g%5B%5D args) %7B%0A
+%0A
         Exec
@@ -422,24 +422,25 @@
 readPool();%0A
+%0A
         Task
@@ -565,141 +565,8 @@
 );%0A%0A
-        try %7B%0A            Thread.sleep(1000);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A
     
@@ -601,17 +601,16 @@
 %E6%89%A7%E8%A1%8C%E4%BB%BB%E5%8A%A1%22);%0A
-%0A
         

update future