| 1. |
What Is Readwritelock In Java? |
|
Answer» In a multi-threading application multiple reads can occur simultaneously for a shared resource. It is only when multiple writes happen simultaneously or INTERMIX of read and write that there is a chance of writing the wrong value or reading the wrong value. ReadWriteLock USES the same idea in order to BOOST the performance by having separate PAIR of locks. A ReadWriteLock maintains a pair of associated locks -
The read lock may be held simultaneously by multiple reader threads, so long as there are no writers. The write lock is exclusive. In a multi-threading application multiple reads can occur simultaneously for a shared resource. It is only when multiple writes happen simultaneously or intermix of read and write that there is a chance of writing the wrong value or reading the wrong value. ReadWriteLock uses the same idea in order to boost the performance by having separate pair of locks. A ReadWriteLock maintains a pair of associated locks - The read lock may be held simultaneously by multiple reader threads, so long as there are no writers. The write lock is exclusive. |
|