Upload Code
loading-left
loading loading loading
loading-right

Loading

Profile
No self-introduction
codes (1)
A simple example for multithreading and semaphore
no vote
This example implements a reading room model. Suppose there are 8 seats in the reading room and 5 seats in the waiting room. The readers' action will be like this: 1) A reader registers his information in the front desk before he enters the reading room. He logs out after he leaves. The front desk can only handle one reader at one time. 2) If a reader finds out the reading room is full, he will wait in the waiting room. 3) If there are not seats in the waiting room, he will leave. *The main thread will start 20 reader threads. Reader threads will repeat the behavior mentioned above. The behavior of the readers are recorded by printing in the screen and writing into a file.
brian1868
2016-08-23
0
1
No more~