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

Clock.java

home Home   up Up   ( Download )


import java.util.*; import org.taj.ajava.lang.*; public class Clock { private long T = 0; private long period; private ArrayList actorList = new ArrayList(); private Timer timer; private TimerTask task; public Clock(long period) { this.period = period; timer = new Timer(); task = new Task(); } public class Tick { public long value; public Tick(long value) { this.value = value; } } public void subscribe(Actor a) { this.actorList.add(a); } public void unsubscribe(Actor a) { this.actorList.remove(a); } private void sendToAll(){ for (Object o: actorList) { Tick t = new Tick(T); Actor.sendMessage((Actor)o, t); } } private class Task extends TimerTask { public void run() { T++; sendToAll(); } } public void start() { timer.scheduleAtFixedRate(task, 0, period); } public void stop() { task.cancel(); } }