what's the alternative to synchronized {...} in Ja...
# getting-started
b
what's the alternative to synchronized {...} in Java? There's Mutex.withLock but that is a suspend function. When I put Java code in there that blocks, I need to fork off a new Virtual Thread to hook it up with coroutines, losing thread locals. I'm looking for a non suspending lock; from what I can see right now, I need a Java class acting as glue code
✅ 1
y
synchronized exists in the stdlib for JVM
b
it's deprecated though
Hidden since 2.1
y
Check the JVM tab not the JS one
b
oooh
that clears things up
l
Not sure if this is useful to anyone, but in my project I built a set of platform-independent primitives that I can use with both the JVM and the native backends: codeberg.org/loke/…/mpthread.kt