
Philosophers: threads and mutexes
Each philosopher is a thread that takes two forks (mutexes), eats, sleeps and thinks; a monitor thread stops the dinner the moment one of them goes too long without eating, or once everyone has eaten enough.
The demo below replays the same rules on a virtual clock, so you can watch the forks change hands at any speed. Its logs match the compiled program's.
Scope & impact
Pick a preset or type the program's arguments: number_of_philosophers time_to_die time_to_eat time_to_sleep [meals].