Skip to content

Latest commit

 

History

History
7 lines (6 loc) · 839 Bytes

File metadata and controls

7 lines (6 loc) · 839 Bytes

java-multithread-2_in_Critical-Section

Consider a scenario where students go to library, students study and students leave the library.
There will be 2 students in the library initially and other 3 will be entering the library.
The condition is that at any point of time there should be at least 2 students studying in the library.(eg if there are only 2 students left in the library and if 1 student is studying then the other student cannot leave.
The last student can only leave once the student who was studying is done studying). You should print the states of the each student whenever they are entering the library, studying or leaving the library and also the total number of students left in the library. Implement this using semaphore