Not at all — in java a method can be both, depending on where it’s called from. You simply don’t have to care about it, you just do it within a virtual thread at invocation time and it will be magically non-blocking.
No it won't be magically non-blocking. You will block your fiber (virtual thread), which could be the thread of execution (not an OS thread, but the logical thread) required to unblock another resulting in an application dead lock
When your application enters a logical catch 22 and can no longer progress
As an example, trying to non-atomically lock 2 mutexes, thread A locks #1 then #2, thead be locks B then A, now let's say they both succeed in locking their first, now they've hit a deadlock as they wait indefinitely for the other mutex to be unlocked
The same is true of asynchronous code, no matter what form it takes (be it threading, be it stackful coroutines, be it stackless coroutines). If A is waiting for B to to do something, B is waiting for C to do something, and C is waiting for A, you get a deadlock
-3
u/cs_office Sep 21 '24
Whether a function is blocking or not is now contained within your documentation instead of within your type system. This is a huge downgrade