Towards generating thread-safe classes automatically

Haichi Wang, Zan Wang, Jun Sun, Shuang Liu, Ayesha Sadiq, Yuan Fang Li

Research output: Chapter in Book/Report/Conference proceedingConference PaperResearchpeer-review


The existing concurrency model for Java (or C) requires programmers to design and implement thread-safe classes by explicitly acquiring locks and releasing locks. Such a model is error-prone and is the reason for many concurrency bugs. While there are alternative models like transactional memory, manually writing locks remains prevalent in practice. In this work, we propose AutoLock, which aims to solve the problem by fully automatically generating thread-safe classes. Given a class which is assumed to be correct with sequential clients, AutoLock automatically generates a thread-safe class which is linearizable, and does it in a way without requiring a specification of the class. AutoLock takes three steps: (1) infer access annotations (i.e., abstract information on how variables are accessed and aliased), (2) synthesize a locking policy based on the access annotations, and (3) consistently implement the locking policy. AutoLock has been evaluated on a set of benchmark programs and the results show that AutoLock generates thread-safe classes effectively and could have prevented existing concurrency bugs.

Original languageEnglish
Title of host publicationProceedings - 2020 35th IEEE/ACM International Conference on Automated Software Engineering, ASE 2020
EditorsClaire Le Goues, David Lo
Place of PublicationNew York NY USA
PublisherIEEE, Institute of Electrical and Electronics Engineers
Number of pages13
ISBN (Electronic)9781450367684
Publication statusPublished - 2020
EventAutomated Software Engineering Conference 2020 - Virtual, Melbourne, Australia
Duration: 21 Sep 202025 Sep 2020
Conference number: 35th (Proceedings) (Website) (Proceedings)


ConferenceAutomated Software Engineering Conference 2020
Abbreviated titleASE 2020
Internet address


  • concurrency
  • locking policy
  • thread safe class

Cite this