[concurrency-interest] problem with ReentrantReadWriteLock toimplement atomic function

Joe Bowbeer joe.bowbeer at gmail.com
Tue Jun 20 04:57:59 EDT 2006


On 6/20/06, Kolbjørn Aambø <kaa at pax.priv.no> wrote:
>
> I suspect that the maximum number of locks (65536 recursive write locks and
> 65536 read locks) happen to be the problem here. I'm trying to find out how
> to make  an atomic put function using ReentrantReadWriteLock without getting
> problems with this limitation.
>

That seems likely.  The exception was probably thrown from r.unlock()
inside a finally block -- after w.lock() or r.lock() threw an Error.

(If you were to retain this code I'd suggest adding a "locked" flag
and/or more try-finally nesting in order to disambiguate this
condition. This would also protect against "put" failures, as David
points out.)

--Joe



More information about the Concurrency-interest mailing list