Grokking Multithreading and Concurrency for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
2. Read/Write Locks
On this page

In this demonstration, we interact with a shared variable, counter, that is accessed concurrently by multiple threads. Specifically, we spawn 2 writer threads that increment the counter in a loop and 8 reader threads that continuously read its value. The program is designed to terminate once the counter reaches the TARGET_VALUE.

Key principles to note in this scenario include:

  • Multiple threads can simultaneously read the value of the counter without blocking each other.

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page