Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • Without the logLock, the code is effectively synch(out); synch(b) {synch(out); } and likely to deadlock. Commented Jan 23, 2024 at 12:39
  • @DuncG That was my original thought, if the VT version some how wasn't releasing out you get the double locking deadlock. Where you can avoid the dead lock by making sure you always acquire the locks in the same order. Commented Jan 23, 2024 at 12:43
  • I am able to reproduce this in 90% of the attempts, and every time the test hangs there is a pinned thread that never reaches "starting" point. Can this situation be correctly called a "deadlock"? It seems to me no, in the sense of Dining Philosophers. Commented Jan 23, 2024 at 12:56
  • 3
    Interestingly, such an example has been found half a year ago already. Performing computeIfAbsent inside a synchronized block defeats the entire purpose of ConcurrentHashMap. But the function passed to computeIfAbsent should not perform blocking operations. Commented Jan 23, 2024 at 18:06
  • Pinning is going to happen only in native code, soon. Commented Jun 25, 2024 at 7:30