Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

What is the point of Futures if everything is blocking?

Javascript • Asked by JonathanFernas

I come from a JS background so bear with me.

The biggest thing about Node is that, although it’s single threaded, you have the event loop and async IO, so promises just make so much sense.

Let’s say you have a web app, you send a query to the DB, then do something with it, then maybe read some other stuff and ultimately return something. While you’re waiting for the IO you can start/process other requests in the meantime.

In Java you have futures and I guess DeferredResult (Spring) which can help make it similar to node. However, any Hibernate calls will be blocking, any IO you do is blocking, etc. unless you do it in a separate thread (but then that defies the point of futures IMO since you’re just spinning more threads).

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,575+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.