Java Deadlock Example
In the last Informatics class 1995/96 (grade 13) we did a project on Petri Nets. Even after leaving school some students continued working on this topic and still do. As an exercise for learning JAVA, Jochen Notholt implemented one of our simple examples as a Java applet.
If your browser supports Java applets, you can try out how a certain subtype of Petri Net (a so called Place-Transition-Net) works.
(If you want to restart the applet, you might not succeed with Netscape. With some versions, and the only way to restart an applet is to click on the URL in the "Location:" - line, and then hit ENTER.)
You might find out the Petri Net's behaviour by clicking on the green squares or you can read the following simplified rules first:
The squares are called transitions, the circles are places. Each place can hold an unlimited number of tokens.
There are arrows (edges), each connecting a transition with a place. Those places with an edge to a transition are the pre set of this transition, those with edges coming from the transition constitute the post set of the transition.
If there is at least one token in each place of a transition's pre set, the transition is activated and shown in green color.
An activated transition can fire by taking a token from each of the places of its pre set and placing a new token in each of the post set places.
Petri Nets are made to model concurrent processes. You can think of it as
a generalization of the well known finite automaton. Other than it
might seem with this example, transitions can fire simultaneously.
The tokens should be seen as preconditions for actions that are represented
by the transitions of the net. Some Petri Nets can go on for ever, others
like this one will eventually have to stop with no transition activated.
Look here for more accurate information on the different types of Petri Nets.