Safe Futures for Java

Welc, Adam and Jagannathan, Suresh and Hosking, Antony L.


A future is a simple and elegant abstraction that allows concurrency to be expressed often through a relatively small rewrite of a sequential program. In the absence of side-effects, futures serve as benign annotations that mark potentially concurrent regions of code. Unfortunately, when computation relies heavily on mutation as is the case in Java, its meaning is less clear, and much of its intended simplicity lost.

This paper explores the definition and implementation of safe futures for Java. One can think of safe futures as truly transparent annotations on method calls, which designate opportunities for concurrency. Serial programs can be made concurrent simply by replacing standard method calls with future invocations. Most significantly, even though some parts of the program are executed concurrently and may indeed operate on shared data, the semblance of serial execution is nonetheless preserved. Thus, program reasoning is simplified since data dependencies present in a sequential program are not violated in a version augmented with safe futures.

Besides presenting a programming model and API for safe futures, we formalize the safety conditions that must be satisfied to ensure equivalence between a sequential Java program and its future-annotated counterpart. A detailed implementation study is also provided. Our implementation exploits techniques such as object versioning and task revocation to guarantee necessary safety conditions. We also present an extensive experimental evaluation of our implementation to quantify overheads and limitations. Our experiments indicate that for programs with modest mutation rates on shared data, applications can use futures to profitably exploit parallelism, without sacrificing safety.

  author = {Welc, Adam and Jagannathan, Suresh and Hosking, Antony L.},
  title = {Safe Futures for {J}ava},
  booktitle = {ACM SIGPLAN Conference on Object-Oriented Programming,
                    Systems, Languages, and Applications},
  series = {OOPSLA},
  year = {2005},
  pages = {439--453},
  month = {October},
  address = {San Diego, California},
  doi = {10.1145/1094811.1094845},
  acm = {},
  gscholar = {178}