r/programming • • Sep 19 '24

Java 23 has released

https://blogs.oracle.com/java/post/the-arrival-of-java-23
302 Upvotes

79 comments sorted by

View all comments

Show parent comments

1

u/cs_office Oct 05 '24

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

1

u/Practical_Cattle_933 Oct 05 '24

Do you even know the definition of a deadlock?!

1

u/cs_office Oct 05 '24 edited Oct 05 '24

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

1

u/Practical_Cattle_933 Oct 05 '24

So yes, it can deadlock, but it won’t on its own. And async-await is also not deadlock-free.

→ More replies (0)