Im a c# developer and now started transitioning to Java...and started comparing the features
i came across this Future in Java concurrency https://docs.oracle.com/javaee/6/tutorial/doc/gkkqg.html As per the documentation example it says Even if the payment processor takes a long time, the client can continue working, and display the result when the processing finally completes.
So can we assume Future is same as c# async await..if not please lemme know the difference...
As per my knowledge sync ,await i have used in mobile operations where we didnt want the UI thread to be blocked while it interacts with apis or service.
Future
is just an interface. It is not capable of handling anything asynchronously by itself. You receive a Future
object when you submit some work to be executed asynchronously in an ExecutorService
. Use Future.get()
to block the current thread until the result is ready. Of course you should do something useful in the current thread between the time you submit the work and try to get the result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With