A simple read-write lock implementation. Multiple threads may lock using
readLock(), only one can lock using writeLock(). The caller is responsible
for coding a try-finally that ensures unlock() is called for every readLock()
and writeLock() call.
A ReadWriteLock is recursive; with one exception, a thread can re-lock an
object it already has locked. Multiple read locks can be acquired by the
same thread, as can multiple write locks. The exception however is that a
write lock cannot be acquired when a read lock is already held (to allow
this would cause deadlocks).
Successive lock calls from the same thread must be matched by an
equal number of unlock() calls.
author: Mike Martin version: $Revision: 1.3 $ |