Make delicious recipes!

Read-Write Lock

ReadWriteLock maintains a pair of associated locks - one for reading and other for writing operation. ReadLock in this pair may be held simultaneously by multiple reader threads, so long as there are no writers. WriteLock is exclusive.

It has two methods :

1) Lock readLock ()

2) Lock writeLock ()

So, you create an instance of ReadWriteLock and then obtain the two locks using the 2 methods above. Then while reading, readLock is locked/unlocked and while writing, writeLock is locked/unlocked.

Like us on Facebook to remain in touch
with the latest in technology and tutorials!

Got a thought to share or found a
bug in the code?
We'd love to hear from you:

Email: (Your email is not shared with anybody)

Facebook comments:

Site Owner: Sachin Goyal