I'm trying to reimplement JRuby's version of Ruby's Mutex class, a non-reentrant locking mechanism. One of the properties of a Mutex is that when the thread holding its lock dies, the lock is released:
~/projects/jruby ➔ ruby -rthread -e "m = Mutex.new; Thread.new { m.lock; p m.locked? }.join; p m.locked?" true false Previously our implementation simply maintained a volatile reference to the thread owning the lock, considering it unlocked if the thread was no longer alive. However that implementation did not use any JVM-level monitor state, so it was not possible for Hotspot to detect deadlocks between two threads trying to mutually acquire the same locks in different order. A modified version that uses ReentrantLock does show up in Hotspot's deadlock detection, but does not appear to release locks on thread death: ~/projects/jruby ➔ jruby -rthread -e "m = Mutex.new; Thread.new { m.lock; p m.locked? }.join; p m.locked?" true true Am I forced to use my own locking mechanism to get on-death lock releasing, or is there some mechanism in java.util.* I've overlooked? - Charlie -- You received this message because you are subscribed to the Google Groups "JVM Languages" group. To post to this group, send email to jvm-languages@googlegroups.com. To unsubscribe from this group, send email to jvm-languages+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jvm-languages?hl=en.