Inter-applet communication, Mark II

This is another approach to inter-applet communication, using a static class with synchronized methods to pass values. I've used integers to represent the items being passed back and forth, but it could be data of any type. The idea: each applet that wants to communicate creates an instance of the Middleman class. The applet calls getInt() to get the value currently stored in the Middleman class, and putInt() to set the value to a new value. In this particular example, I've got 5 instances of an applet that reads the value stored in the Middleman class increments it by 1, and puts it back. Note the use of the synchronized keyword to ensure that no 2 instances of an applet modify the value simultaneously.


Source for the Applet
Source for the Middleman class