3 ms·
And now Java is benifiting from being a second mover on a lot of the features C# adopted. See virtual threads vs async/await. Java's version is going to be bet
by vips7L 6y ago
And now Java is benifiting from being a second mover on a lot of the features C# adopted.
See virtual threads vs async/await. Java's version is going to be better.
- pjmlp 6y agoI always end up with a couple of Task.Run() calls, because cannot change the complete call chain to deal with async/await.
- fomine3 6y agoEven that situation, you can still use await inside Task.Run, it should be useful than nothing.
- Const-me 6y agoIf you want to avoid changing the complete chain to Task, there’re workarounds. You can block the caller thread waiting for the task. Deadlocks are possible with this approach due to synchronization context shenanigans, but they’re easy to fix, VS debugger is quite good at multithreading. Another method, you can run whatever dispatcher on your main thread, in modern .NET that’s usually Dispatcher.PushFrame. Also, if the async method returns no values, you don’t need to change the call chain, you just need to catch and handle exceptions.