Acquire the write lock, blocking until the write lock is available. Only one writer can acquire the write lock, and when held, no readers can acquire the read lock.
If there are no readers and no waiting writers, mark as having an active writer and return. Otherwise, add a lock to the end of the waiting writer list, and block on it. Caller must call releaseWrite when done (for example, in a finally block).
|
|
|
|