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

ListIterator.java

home Home   up Up   ( Download )


import java.util.List; import org.taj.ajava.lang.*; public class ListIterator extends Actor { private List list; public ListIterator(List list) { this.list = list; } public static class Run { } private void react_0(Run r) { if (list.size() > 0) this.react(list.size() - 1); } public void deliver(Run r) { bufferMessage(new org.taj.ajava.runtime.ActorMessage(r, 0)); } protected void react(Run r) { react_0(r); } private void react_1(Object v) { } public void deliver(Object v) { bufferMessage(new org.taj.ajava.runtime.ActorMessage(v, 1)); } protected void react(Object v) { react_1(v); } private void react_2(int it) { this.react(list.get(it)); if (it > 0) this.deliver(it - 1); } private void deliver(int it) { bufferMessage(new org.taj.ajava.runtime.ActorMessage(new Integer(it), 2)); } protected void react(int it) { react_2(it); } protected void processMessage(org.taj.ajava.runtime.ActorMessage msg) { switch (msg.reactorId) { case 0: { react_0(((Run)msg.payload)); return; } case 1: { react_1(((Object)msg.payload)); return; } case 2: { react_2(((Integer)msg.payload).intValue()); return; } default: { super.processMessage(msg); return; } } } }