Microsoft | Create simple read write lock

Use synchronized, wait() and notify() to write a program such that below mentioned conditions are fulfilled while reading and writing data to a shared resource.

  1. When a write is happening, no read or other write should be allowed(read and write threads should wait)

  2. When a read is happening, no write should be allowed (write threads should wait) but. other read threads should be able to read.

Donot use any API classes e.g. ReadWriteLock, AtomicInteger etc..

Comments (1)