ActiveJava

Copyright Tristan Aubrey-Jones May 2008.

Abstract: A project investigating and developing an implicitly concurrent programming language, based on a metaphor taken from the physical world is reported. Uses a programming paradigm where programs consist of systems of autonomous agents, or active objects which communicate via message passing. A language enhancing Java with actors and linear types is presented. Example programs are written, compiled, and executed to evaluate the usefulness of the language. The language found to provide a familiar notation for implicit parallelism, and a compelling new model for concurrency, combining the performance of shared variables with the elegance of message passing.

Introductory Slides (PDF), Report (PDF),
ActiveJava compiler prototype (ajavac), ActiveJava runtime library (ajava_lang).

Examples:

calc - pocket calculator actor program
dining - dining philosophers actor program (never deadlocks)
sort - parallel quicksort implementation ("SortBenchmark" sorts 10,000 random integers using actors, java threads, and sequentially and compares)
To compile examples use:
compile.bat ./calc
compile.bat ./sort
compile.bat ./dining
To run examples use:
run ./calc Main
run ./dining Main
run ./dining Main fast
run ./sort Main
run ./sort SortingBenchmark

AFrame.java

home Home   up Up   ( Download )


import javax.swing.*; import java.awt.*; import java.awt.event.*; import org.taj.ajava.lang.*; public class AFrame extends AComponent { protected JFrame frame; protected AContainer contentPane; public AFrame(String title) { super(new JFrame(title)); frame = ((JFrame)component); Container cp = frame.getContentPane(); contentPane = new AContainer(cp); } public AFrame() { this("AJava Window"); } public static class Show { } private void react_0(Show cmd) { frame.show(); } public void deliver(Show cmd) { bufferMessage(new org.taj.ajava.runtime.ActorMessage(cmd, 0)); } protected void react(Show cmd) { react_0(cmd); } public static class Hide { } private void react_1(Hide cmd) { frame.hide(); } public void deliver(Hide cmd) { bufferMessage(new org.taj.ajava.runtime.ActorMessage(cmd, 1)); } protected void react(Hide cmd) { react_1(cmd); } public static class SetCloseOperation { public static final int DO_NOTHING_ON_CLOSE = WindowConstants.DO_NOTHING_ON_CLOSE; public static final int EXIT_ON_CLOSE = WindowConstants.EXIT_ON_CLOSE; public static final int HIDE_ON_CLOSE = WindowConstants.HIDE_ON_CLOSE; public int op; public SetCloseOperation(int op) { this.op = op; } } private void react_2(SetCloseOperation s) { frame.setDefaultCloseOperation(s.op); } public void deliver(SetCloseOperation s) { bufferMessage(new org.taj.ajava.runtime.ActorMessage(s, 2)); } protected void react(SetCloseOperation s) { react_2(s); } protected void processMessage(org.taj.ajava.runtime.ActorMessage msg) { switch (msg.reactorId) { case 0: { react_0(((Show)msg.payload)); return; } case 1: { react_1(((Hide)msg.payload)); return; } case 2: { react_2(((SetCloseOperation)msg.payload)); return; } default: { super.processMessage(msg); return; } } } }