This applet demonstrates a simple Java solution to the classic Dining Philosopher's Problem. To use the applet, click on the START button and watch the fun. For a deeper explanation of the problem and the display, consult the text at the bottom of this page.
The dining philosopher's problem is a classic one in the area of concurrent systems. It goes like this:
Five philosophers are sitting around a round table. Each has in front of him a bowl of rice. Between each philosopher and his neighbor is a chopstick; five chopsticks in all. Each philosopher thinks for a while, then gets hungry and wants to eat. In order to eat, he has to get two chopsticks. Once he possesses two chopsticks, he will eat for a while, then put both chopsticks back down on each side.
This problem illustrates the potential problem of deadlock. If each philosopher merely picks up the chopstick on his left, for example, then all five of them will starve to death.
Anyway, in the applet above, you can play with different numbers of dining philosophers. In the diagram, each chopstick on the table is represented by a little stick, and each philosopher is represented by a circle. The color of the circle represented the philosopher's state: thinking, waiting to eat, eating, and done.
To use the applet, just type a number into the text field, and click on the START button. To slow down the action, check the box marked Slow.
[Ziring MicroWeb Home] [Back to Java Page] [Sign Guestbook]
This page written by Neal Ziring, last modified 1/15/99.