[concurrency-interest] ReentrantReadWriteLock should throw ex on writeLock().lock() if read lock held?
giuliano.mega at gmail.com
Tue Sep 5 09:57:25 EDT 2006
I always thought that Lock.tryLock was supposed to play this role
(except that it returns false instead of throwing an exception). Am I
missing something from your problem that prevents you from using
On 9/5/06, Jed Wesley-Smith <jed at atlassian.com> wrote:
> 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 :-)
> - jed.
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
Giuliano Mega <giuliano at ime.usp.br>
More information about the Concurrency-interest