Description: The philosopher's eating problem - the Java language implementation
The philosopher's eating problem is a classic example of multi-threading, involving thread synchronization/mutual exclusion, critical area access problems, and a solution to avoid deadlocks.
There were five philosophers who sat around the round table, and each philosopher had a dish in front of him, and there was a chopstick between them, so that each philosopher had a pair of chopsticks.
Philosophers have two states, think or pick up chopsticks to eat. If philosophers get a chopstick, they can't eat, until they get two to eat, and can only pick up one of their chopsticks at a time. Once you have picked up, you will not put down your chopsticks until you have finished eating.
If, unfortunately, every philosopher picks up his or her left chopsticks, no one can eat. This will cause a deadlock. This is something that needs to be firmly eliminated, just as the operating system's deadlock problem.
To Search:
File list (Check if you may need any files):