5 ms·
great, now you have futures AND virtual threads. soo much better!
by merb 4y ago
great, now you have futures AND virtual threads. soo much better!
- gpderetta 4y agoIt is significantly better. The issue with futures is chaining them together and having to thread continuations by hand. Async/await is an improvement over that, but when you can just block instead they become much nicer to use.
- kagakuninja 4y agoJava Futures are lobotomized. What is really nice is to treat Futures as monads (as in Scala, and FP languages like Haskell). Then you can chain them together using calls to flatMap aka bind. Then you can use for-comprehensions (or the equivalent): for { a <- taskA b <- taskB c <- taskC } yield a + b + c There are a ton of other fancy tricks found in Haskell or libraries such as Cats.
- krackers 4y agoYou can have futures with "real threads" as well, futures are merely an abstraction to getting "output" of a thread in a non-blocking fashion.