Abstracts - 2006
JCilk -- A Java-Based Multithreaded Programming Language
I-Ting Angelina Lee & Charles E. Leiserson
JCilk is a Java-based multithreaded language for parallel programming that extends the semantics of Java by introducing "Cilk-like"  linguistic constructs for parallel control. The original Cilk language provides a dynamic multithreading model that supports call-return semantics in a C language context. The Cilk system also includes a provably good scheduler that guarantees programs can take full advantage of the resources available at runtime. Cilk, as an extension of C, lacks support for such modern language features as objects and exceptions. Java, on the other hand, provides many desirable modern language features such as automated memory management, an exception-handling mechanism, and inheritance, but it lacks a good dynamic threading model. Java's built-in threading is static, that is, threads are created explicitly to execute code specified by the user at compile time, with no correlation between the number of threads created by the running program and the resources available to it. Java's threading model also does not support the passing of exceptions or return values from one thread back to its "parent" thread. JCilk supplies Java with a dynamic threading model and the ability for methods to be executed in parallel and return their results to the methods that called them.
Language Design and Features
JCilk introduces three keywords into Java:
Since Java allows a method to signal an exception rather than return
normally, JCilk's semantics must extend the Cilk semantics to handle this
possibility. A method generally throws an exception to indicate that it
has completed abnormally or unsuccessfully. When this happens in Java,
control is passed to the nearest dynamically enclosing
Aborting might cause a computation to be interrupted asynchronously,
causing havoc in programmer understanding of code behavior, however. To
simplify the reasoning of program states when abort occurs, JCilk only
The JCilk system consists of two components: a runtime system and a
compiler. JCilk's runtime system implements a Cilk-like work-stealing
scheduling algorithm [1, 4] that schedules
threads dynamically according to available system resources. Depending
on the resources availability, a method which began to execute on one
processor may migrate to continue execution on another processor to create
parallelism. This code migration requires a continuation mechanism, which
is provided by the compiler. We support a continuation mechanism without
slowing down pure Java code by creating an intermediate language called
GoJava. This language is a minimal extension of Java that allows the
We have designed a semantics for JCilk in general, and for exception handling in particular, which gracefully extends the Java language to include the Cilk primitives. This extension is "faithful" in that it obeys Java's ordinary serial semantics when a program is executed on a single processor. On multiple processors, it allows parallelism while still making it easy to reason about how a program behaves.
Regarding implementation, we have already built a working version of the JCilk system that handles the parallel exception semantics that we have designed. Currently, we are still working on improving the system performance.
We hope to use JCilk to further explore the interaction between the sometimes-arcane world of parallel computing and the day-to-day world of commodity serial computing. In particular, there are two possible directions that we are heading. First, there is currently a sharp delineation between Cilk methods and non-Cilk Java methods. One fertile topic for future research is to design a mechanism to break this barrier between Java and JCilk. Second, JCilk supports a dynamic threading model, which is quite different from Java's static threading model. We like to eventually provide both threading models in JCilk, although at this point we are not clear how threads from two models should interact and communicate with each other. It will take some thorough consideration to come up with a sophisticated model that encompasses both threading models and incorporates them harmoniously.
The research described in this abstract represents a collaborative work with John S. Danaher, who graduated in June 2005. Special thanks to John, who took part in designing the JCilk semantics for exception handling, and developed the JCilk runtime system.
Thanks to Christine Flood for helping us running some experiments for performance study. Thanks to Dave Dice for helpful discussions regarding timing in Java. Thanks to Kunal Agrawal, Scott Ananian, Jeremy Fineman, Viktor Kuncak, Bradley Kuszmaul, Edya Ladan Mozes, Martin Rinard, and Jim Sukha of MIT CSAIL, Jan-Willem Maessen of Sun Microsystems, Gideon Stupp of Tel Aviv University, and Wong Weng Fai of National University of Singapore for helpful discussions in general.
This research is supported in part by the Singapore-MIT Alliance and by NSF Grant ACI-0324974 and CNS-0305606. I-Ting Angelina Lee is supported by Sun Microsystems Fellowship.
 J. S. Danaher, I.-T. A. Lee, and C. E. Leiserson. The JCilk Language for Multithreaded Computing. In Proceedings of the Synchronization and Concurrency in Object-Oriented Languages (SCOOL), San Diego, California, October 2005.
 M. Frigo, C. E. Leiserson, and K. H. Randall. The implementation of the Cilk-5 multithreaded language. In Proceedings of the ACM SIGPLAN '98 Conference on Programming Language Design and Implementation, pages 212-223, Montreal, Quebec, Canada, June 1998. Proceedings published ACM SIGPLAN Notices, Vol. 33, No. 5, May, 1998.
 N. Nystrom, M. Clarkson, and A. C. Myers. Polyglot: An extensible compiler framework for Java. In Proceedings of the 12th International Conference on Compiler Construction, pages 138-152. Springer-Verlag, Apr. 2003.