Read Lock vs Write Lock

A lock is a synchronization primitive which limits access to a shared resource among multiple threads. We don’t need locks when only one thread is running or there is no shared resource because a lock is always acquired on a shared resource. Let’s look at what locks can be acquired. Read Lock Multiple threads can …