Loci: Simple Thread-Locality for Java

  • Tobias Wrigstad
  • Filip Pizlo
  • Fadi Meawad
  • Lei Zhao
  • Jan Vitek
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5653)


This paper presents a simple type system for thread-local data in Java. Classes and types are annotated to express thread-locality and unintended leaks are detected at compile-time. The system, called Loci, is minimal, modular and compatible with legacy code. The only change to the language is the addition of two new metadata annotations. We implemented Loci as an Eclipse plug-in and used it to evaluate our design on a number of benchmarks. We found that Loci is compatible with how Java programs are written and that the annotation overhead is light thanks to a judicious choice of defaults.


Java Program Shared Object Ownership Type Data Race Current Thread 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Java theory and practice: Synchronization optimizations in mustang,
  2. 2.
    Aldrich, J., Chambers, C., Sirer, E.G., Eggers, S.J.: Static analyses for eliminating unnecessary synchronization from Java programs. In: SAS, pp. 19–38 (1999)Google Scholar
  3. 3.
    Bacon, D.F., Konuru, R., Murthy, C., Serrano, M.: Thin locks: Featherweight synchronization for Java. In: PLDI, pp. 258–268 (1998)Google Scholar
  4. 4.
    Bacon, D.F., Strom, R.E., Tarafdar, A.: Guava: a dialect of Java without data races. In: OOPSLA, pp. 382–400 (2000)Google Scholar
  5. 5.
    Blackburn, S.M., et al.: The DaCapo benchmarks: Java benchmarking development and analysis. In: OOPSLA, pp. 169–190 (2006)Google Scholar
  6. 6.
    Blanchet, B.: Escape analysis for object-oriented languages: application to Java. In: OOPSLA, pp. 20–34 (1999)Google Scholar
  7. 7.
    Bogda, J., Hölzle, U.: Removing unnecessary synchronization in Java. In: OOPSLA, pp. 35–46 (1999)Google Scholar
  8. 8.
    Borman, S.: Sensible sanitation – understanding the IBM Java garbage. IBM DeveloperWorks (August 2002)Google Scholar
  9. 9.
    Boyapati, C., Lee, R., Rinard, M.: Ownership Types for Safe Programming: Preventing Data Races and Deadlocks. In: OOPSLA, pp. 211–230 (2002)Google Scholar
  10. 10.
    Choi, J.-D., Gupta, M., Serrano, M., Sreedhar, V.C., Midkiff, S.: Escape analysis for Java. In: OOPSLA, pp. 1–19 (1999)Google Scholar
  11. 11.
    Choi, J.-D., Gupta, M., Serrano, M.J., Sreedhar, V.C., Midkiff, S.P.: Stack allocation and synchronization optimizations for Java using escape analysis. ACM Trans. Program. Lang. Syst. 25(6), 876–910 (2003)CrossRefGoogle Scholar
  12. 12.
    Clarke, D.: Object Ownership and Containment. PhD thesis, University of New South Wales, Australia (2001)Google Scholar
  13. 13.
    Clarke, D., Wrigstad, T.: External uniqueness is unique enough. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 176–200. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  14. 14.
    Clarke, D., Wrigstad, T., Östlund, J., Johnsen, E.B.: Minimal Ownership for Active Objects. Technical Report SEN-R0803, CWI (2008)Google Scholar
  15. 15.
    Clarke, D.G., Potter, J., Noble, J.: Ownership types for flexible alias protection. In: OOPSLA, pp. 48–64 (1998)Google Scholar
  16. 16.
    Cunningham, D., Drossopoulou, S., Eisenbach, S.: Universe Types for Race Safety. In: VAMP 2007, September 2007, pp. 20–51 (2007)Google Scholar
  17. 17.
    Domani, T., Goldshtein, G., Kolodner, E.K., Lewis, E., Petrank, E., Sheinwald, D.: Thread-local heaps for Java. In: ISMM, pp. 76–87 (2002)Google Scholar
  18. 18.
    Flanagan, C., Freund, S.N., Lifshin, M., Qadeer, S.: Types for atomicity: Static checking and inference for Java. ACM TOPLAS 30(4), 1–53 (2008)CrossRefGoogle Scholar
  19. 19.
    Flanagan, C., Qadeer, S.: A type and effect system for atomicity. In: PLDI, pp. 338–349 (2003)Google Scholar
  20. 20.
    Goetz, B.: Java theory and practice: Urban performance legends, revisited. IBM DeveloperWorks (September 2005)Google Scholar
  21. 21.
    Jikes RVM homepage,
  22. 22.
    Joisha, P.G.: Compiler optimizations for nondeferred reference: counting garbage collection. In: ISMM, pp. 150–161 (2006)Google Scholar
  23. 23.
    Müller, P.: Modular Specification and Verification of Object-Oriented Programs. Springer, Heidelberg (2002)CrossRefzbMATHGoogle Scholar
  24. 24.
    Noble, J., Vitek, J., Potter, J.: Flexible alias protection. In: Jul, E. (ed.) ECOOP 1998. LNCS, vol. 1445, pp. 158–185. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  25. 25.
  26. 26.
    Östlund, J., Wrigstad, T., Clarke, D., Åkerblom, B.: Ownership, uniqueness and immutability. In: TOOLS (2007)Google Scholar
  27. 27.
    Pizlo, F., Hosking, A.L., Vitek, J.: Hierarchical real-time garbage collection. In: LCTES, pp. 123–133 (2007)Google Scholar
  28. 28.
    Potanin, A.: Generic Ownership—A Practical Approach to Ownership and Confinement in OO Programming Languages. PhD thesis, Victoria University of Wellington (2007)Google Scholar
  29. 29.
    Russell, K., Detlefs, D.: Eliminating synchronization-related atomic operations with biased locking and bulk rebiasing. In: OOPSLA, pp. 263–272 (2006)Google Scholar
  30. 30.
    Spring, J.H., Privat, J., Guerraoui, R., Vitek, J.: StreamFlex: High-throughput Stream Programming in Java. In: OOPSLA, pp. 211–228 (2007)Google Scholar
  31. 31.
    Srinivasan, S., Mycroft, A.: Kilim: Isolation-typed actors for java. In: Vitek, J. (ed.) ECOOP 2008. LNCS, vol. 5142, pp. 104–128. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  32. 32.
    Steensgaard, B.: Thread-specific heaps for multi-threaded programs. In: ISMM, pp. 18–24 (2000)Google Scholar
  33. 33.
    Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Inf. Comput. 115(1), 38–94 (1994)MathSciNetCrossRefzbMATHGoogle Scholar
  34. 34.
    Wrigstad, T.: Ownership-Based Alias Management. PhD thesis, Royal Institute of Technology, Kista, Stockholm (2006)Google Scholar
  35. 35.
    Wrigstad, T., Clarke, D.: Existential owners for ownership types. Journal of Object Technology 4(6), 141–159 (2007)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Tobias Wrigstad
    • 1
  • Filip Pizlo
    • 1
  • Fadi Meawad
    • 1
  • Lei Zhao
    • 1
  • Jan Vitek
    • 1
  1. 1.Computer Science Dept.Purdue UniversityUSA

Personalised recommendations