Netflix/curator — Issue #31: InterProcessMutex from multiple threads
Author: maddogg14524
Created: 2012-02-23 04:16:06+00:00
State: open

I started testing with the InterProcessMutex today and was surprised to find out that it threw an IllegalMonitorException if another thread in the same jvm already had the lock. What I expected was behaviour within the same jvm similar to Java's standard ReentrantLock.

What are the best practices for the case where one would like the lock to be shared both within and across jvms? What I can do short term is to try/catch the illegal monitor exception everywhere I need to call the lock but that seems cludgy and is less than ideal. It seems like to get the behaviour I would really want the acquire method would need the ability to block.