GJ

Home
Mirrors
Distribution
Documents
Applications
People
Related

A Generic Java Language Extension

Synchronous Communications and the Sieve of Eratosthenes

This page demonstrates a GJ package for synchronous communication via channels between threads. Interactions between processes are displayed on a message sequence chart. Thanks to GJ, channels can be of any type, and the GJ compiler checks that the message type conforms to the channel type. Heavy use is also made of the Java collection library.

The demonstration implements the Sieve of Eratosthenes, computing primes with a collection of concurrent processes. Pressing either again button re-executes the sieve, usually yielding a different interleaving of processes. In this example, most messages are of type Integer, but the `done' messages are of type String.

The communications library and sieve were written by Philip Wadler. The applet runs under IE 4.0 or Netscape 4.06 or higher. Here is the source (about 500 lines).


Your browser cannot run Java applets.


Comments and bug reports to the Pizza Group, pizza@cis.unisa.edu.au. Java is a trademark of Sun Microsystems. All software and documents on the Pizza site are © Copyright 1996, 1997 by the respective authors as attributed on each. Terms for redistribution are available.
wadler@research.bell-labs.com