[concurrency-interest] ReentrantReadWriteLock should throw ex on writeLock().lock() if read lock held?
jed at atlassian.com
Tue Sep 5 03:13:57 EDT 2006
Just a quick question regarding the acquisition policy of the
ReentrantReadWriteLock if a reader tries to grab the write lock. What
currently happens is that the call to writeLock().lock() blocks forever.
Wouldn't it be better to throw some sort of exception like
IllegalMonitorStateException (not that one specifically, but something
like it)?. That way you would fail-fast and find the problem fairly
Or in other words, is there a specific reason you would want to call
something in such a way that the only return possible is an
InterruptedException if you are lucky enough that another thread notices
your plight and interrupts you :-)
More information about the Concurrency-interest