Let’s discuss what is Future and how is it used for monitoring a task.

Future, A Token of Task Submission

I believe, the title is very abstract but clearly explains the purpose. The concurrency package is the boss when it’s come to asynchronous programming. Of course, this is the continuation of my previous articles on asynchronous programming.

We have seen creating Threads and make use of Executor Framework for the Thread management. Also, We look at how to submit a task and how is it processed internally in the executor. But we haven’t seen how to check the status or getting the result etc.

That’s the purpose that brought us the Future Interface. Future lies in the same package as other concurrency class that is java.util.concurrent. And It’s available since Java 1.5.

In simple words, a Future is a token of task creation and comes with various methods to check if the computation is complete, to wait for its completion, and to retrieve the result of the computation.

I think It’s enough about the introduction and let’s get our hands dirty.

#java #tutorial #future #java tutorial #async #thread #executor framework

Future, A Token of Task Submission
1.15 GEEK