futuretask

Java Multithreaded Concurrent FutureTask

Java’s multithreading mechanism essentially accomplishes two things, asynchronous computation and concurrency. Concurrency is solved by a series of APIs that address thread safety; asynchronous computation, on the other hand, is commonly used with Runnable and Callable in conjunction with threads. FutureTask is a cancelable asynchronous callable API based on the Runnable implementation. Basic usage Future represents the result of an asynchronous computation, and is executed via the ExecutorService’s Future<? > submit(Runnable task) method of the ExecutorService, which is used as the return value.