2 ms·
> No idea why Thaxll and the other comments are mentioning mutexes. Thaxll mentioned mutexes in a reply to the statement Java has no way to express the concep
by Someone 3y ago
> No idea why Thaxll and the other comments are mentioning mutexes.
Thaxll mentioned mutexes in a reply to the statement
Java has no way to express the concept of "something that nothing else can modify while I'm looking at it"
Even ignoring the performance aspect that is not the perfect answer, though. AFAIK, the JVM doesn’t have a notion of “you can only modify foo if you hold mutex bar”. That remains something the programmer must enforce.
On the other hand, tooling exists to help them, for example https://www.javadoc.io/doc/com.google.code.findbugs/annotations/3.0.1/javax/annotation/concurrent/GuardedBy.html https://www.javadoc.io/doc/com.google.code.findbugs/annotati...