r/javahelp • u/akanshya9z12 • Jun 02 '21
Codeless What is Future class in java?
I saw this class being used in a project recently, which was handling a parallel processing request. Please explain to me in layman terms what is the purpose of this class?
0
Upvotes
2
u/Prateeeek Jun 02 '21
It's like promises in JavaScript, when the result can't be returned right away because an asynchronous task is happening we return a future. That future would then have the value later in time when the asynchronous task has returned a result. We would then use future.get to get the actual value.