Hi all
I am using a ReentrantReadWriteLock in Java.
My problem is to have both readers and writers waiting on the same lock:

Here is a pseudo code example of the reader scheme:
Code:
try{
	readLock.lock()
	read()
	if(there is nothing else to read){
		signal the writeLock
	}
}
finally{
	readLock.unlock()
}
Here is a pseudo code example of the writer scheme:
Code:
try{
	writeLock.lock()
	wait until reader has nothing to read
}
finally{
	writeLock.unlock()
}
The thing is that I am not sure of how to implement the wait and signal mechanisms:
I thought of having a Condition object but each thread (Reader or Writer) owns a different Lock so I can't signal the Writer thread from the Reader thread.
(Actually the readerLock doesn't even have a Condition)
Can anyone suggest a solution?

Thanks
Guy