--java.util.concurrent six: using Future class and Callable class
http://kanglecjr.iteye.com/blog/1071199
--Java.util.concurrent package uses Future, Callable to implement the answering mode
http:/ /blog.csdn.net/u013025830/article/details/51373482
-- Java multithreading ~~~Callable interface to get return valuehttp:
//blog.csdn.net/a352193394/article/details/39505307
--Java multithreading The implementation of the Callable interface
http://www.cnblogs.com/baizhanshi/p/6425209.html
--Callable, Runnable comparison and usage
http://www.cnblogs.com/zeze/p/6293104.html
import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import org.apache.log4j.Logger; public class TaskDemo implements Callable<Boolean> { /** * The CountDownLatch class provides only one constructor: * public CountDownLatch(int count) { }; //The parameter count is the count value * Then the following three methods are the most important methods in the CountDownLatch class: public void await() throws InterruptedException { }; //The thread calling the await() method will be suspended, it will wait until the count value is 0 before continuing to execute public boolean await(long timeout, TimeUnit unit) throws InterruptedException { }; //Similar to await(), except that it will continue to execute if the count value has not become 0 after waiting for a certain period of time public void countDown() { }; //Reduce the count value by 1 * @param args */ private static final Logger LOGGER = Logger.getLogger(TaskDemo.class); private XTargetService xTargetService; private CountDownLatch countDownLatch; public TaskDemo() { super(); } public TaskDemo(XTargetService xTargetService,CurrentContext context, CountDownLatch countDownLatch) { super(); this.xTargetService = xTargetService; this.context = context; this.countDownLatch = countDownLatch; } @Override public Boolean call() throws Exception { try { Thread.sleep(3000); } catch (Exception e) { LOGGER.error("xxxxxx", e); }finally{ if (countDownLatch != null) { countDownLatch.countDown(); } } return true; } }