[ News | IPCA | Mirrors | Add | Search | Mail | Help | WoTUG ]
(Updated 10th February 1997)
This page describes two different Java applets that demonstrate the occam-style CHAN mechanism implemented in Java.
This is a simple applet consisting of two Java threads controlling two elements: a button (control thread) and a label (status thread). The status thread increments the status value every second. If the button is pressed, the control thread sends a message via a CHAN_OF_INT Class (Documentation) to the status thread. When the status thread sees the channel is not-empty (by polling it), the message is read and the counter reset.
See the Source Code of the CHAN_OF_INT class and the StatusControl class (the applet) for further details.
This applet demonstrates a multiple-readers/writers Channel c (Documentation) which carries Java Objects. The applet consists of writer threads on the left and reader threads on the right.
The writers OR readers can be active as buttons in which case the user has control.
When the readers are active, the writers are eager to send and
block on outputing (queueing on the Channel). You can
decide which reader should pick up the next written value by
clicking on one of the Readers. When that happens, the reader
will do a
In this example, the readers are eager to receive and are
blocked on inputting (again queueing on the Channel).
You can decide which writer should send the next value by
clicking on one of the writers. When that happens, the given
Writer will do a
Note: In each of the examples there are Java threads (Active Objects) for each Reader and Writer and a single Channel (Passive Object).
See the Source Code of the Channel class and the ReadChanWrite class (the applet) for further details.
This is the Source Code of the BUFFER_OF_INT class as discussed in the handouts (see main Java Threads Workshop page).