Cava - A New Concurrency Model for Java

Studenteropgave: Kandidatspeciale og HD afgangsprojekt

  • Birthe Damborg
  • Anders Mørk Hansen
4. semester, Datalogi, Kandidat (Kandidatuddannelse)
The goal of the project was to develop a new concurrency model, called Cava, for the Java programming language. The motivation was the increasing need for concurrent programs e.g. to utilise the power of multicore CPUs. Moreover, Java's present concurrency model suffers from various weaknesses such as broken encapsulation and the inheritance anomaly.
Based on an investigation of Java's present concurrency model, design criteria for a new concurrency model were defined: it should comply with the underlying object-oriented model, be expressive, offer fault restriction, and be simple. Assessing the new model was important to evaluate how it met the design criteria. Moreover, it should be investigated whether the new concurrency model is stronger than Java and offers better support for modelling concurrent problems and introducing parallelism. Hence, an assessment method, which assigns a numerical value to a concurrency model, was developed based on posing questions about each design criterion.
Cava builds on Java but the wait, notify, and notifyAll methods were removed along with the synchronized keyword. The fundamental concurrency construct in Cava is still the thread. However, non-deterministic behaviour of threads appears only by choice. Moreover, all variables are thread local unless they are marked as shared between threads with the new shared modifier. Access to shared variables is restricted since it must occur within methods or blocks which are marked with the new transaction keyword. Such methods and blocks apply Software Transactional Memory which allows for performing roll backs in case of conflicts on variables. The transactional status of methods is preserved on inheritance. Cava also features a gate construct which enables sending messages between threads. There are two types of gates: or-gates which forward a message to a single thread, and and-gates which forward a message to multiple threads.
An experimental implementation of Cava was developed as part of the project by changing Sun's Java compiler into a Cava compiler and implementing a Cava Runtime System. The strategy was to hijack the Java compiler which implies that the generated class files can be executed on a standard JVM if the Cava Runtime System is specified to this. The implementation enabled writing and testing Cava programs, e.g. Cava was applied to model a lock, Dining Philosophers, the Santa Claus Problem, and a parallel version of Quicksort.
Cava achieved a better score than Java in the comparison. This was primarily obtained on a significantly better integration with the object-oriented paradigm and more fault restriction. There was a tie with regard to expressiveness while Cava scored slightly worse than Java on simplicity. Since Cava was far from the maximum score, areas of potential future work were presented along with examples of related work.
SprogEngelsk
Udgivelsesdatojun. 2007
ID: 61070569