arXiv:2611.09410cs.PLNov 2026

Manuscript Offprint

arXiv:2611.09410

Nothing Is Shared Until You Synchronise: Reinterpreting Java for Data-Race Freedom

Luke Cheeseman, Elias Castegren, David Black-Schaffer, Erik Österlund, Tobias Wrigstad

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Reinterpreting Java for Data-Race Freedom

LUKE CHEESEMAN, Uppsala University, Sweden

ELIAS CASTEGREN, Uppsala University, Sweden

DAVID BLACK-SCHAFFER, Uppsala University, Sweden

ERIK ÖSTERLUND, Oracle, Sweden

TOBIAS WRIGSTAD, Uppsala University, Sweden

In mainstream shared-memory languages, programmers use synchronisation mechanisms such as locks to isolate shared data accesses across threads to avoid data races. Yet synchronisation enforces only a temporal ordering, while the underlying shared memory continues to communicate updates between threads at every ordinary read and write. To achieve isolation, programmers therefore need to understand the connection between ordering and communication, and to apply synchronisation correctly and consistently on that basis, while compilers and hardware optimise assuming they have. When programmers do not order (synchronise) correctly, they lose isolation, and the semantics of their programs change without notice.

We propose Sync-as-Share, a memory model built on isolation and communication rather than on the ordering of accesses to shared memory. We start from thread isolation, where each thread reads and writes a private view of memory, and reinterpret programs' existing synchronisation actions to take on the additional role of explicitly communicating updates. As nothing is communicated outside of synchronisation actions, data races become impossible by construction. Instead, conflicting updates are now detected at synchronisation points. Importantly, by viewing synchronisation as explicit communication, we are able to identify, expose, and address the underlying synchronisation design decisions of what should be communicated, to whom, and what counts as a conflict. We explore these design decisions in Sync-as-Share and propose two different communication topologies with different trade-offs. To make the implications concrete, we instantiate Sync-as-Share for Java by making the synchronisation actions already defined by its memory model the only points at which threads communicate. Java programs can therefore adopt Sync-as-Share unmodified. We then formalise this instantiation, drawing on version control systems to build version-controlled memory, in which synchronisation actions push and pull updates between private views, and mechanise the formalisation in Rocq. From this we can then show that Java programs that are correctly synchronised (as defined by the current Java memory model) behave identically under shared memory and Sync-as-Share, while providing the benefits of isolation and explicit communication.

1 Introduction

Programmers using shared memory aim to work in isolation and to reason about a thread as if the state it touches were its own. They use synchronisation at the boundaries where that isolation must be broken, so that data can pass from one thread to another. Locks, volatiles, and thread start/join are the vocabulary for those boundaries. But they do not deliver isolation. Instead they enforce a temporal ordering which is only indirectly connected to isolation. Every thread still reads and writes one shared memory, and the mechanisms order threads without denoting the state being handed over. This misalignment places two demands on programmers: they must apply synchronisation correctly and consistently across all accesses to all shared data, and they must understand the language and hardware memory models well enough to know how ordering in time translates into isolation across space. This has proven difficult: programmers do not consistently apply synchronisation correctly [10, 35], the races that result are hard enough to find that a whole

Authors' Contact Information: Luke Cheeseman, Uppsala University, Uppsala, Sweden, luke.cheeseman@it.uu.se; Elias Castegren, Uppsala University, Uppsala, Sweden, elias.castegren@it.uu.se; David Black-Schaffer, Uppsala University, Uppsala, Sweden, david.black-schaffer@it.uu.se; Erik Österlund, Oracle, Stockholm, Sweden, erik.osterlund@oracle.com; Tobias Wrigstad, Uppsala University, Uppsala, Sweden, tobias.wrigstad@it.uu.se.

class of tools exists to find them [3, 23, 46], and understanding how ordering translates into isolation for incorrectly synchronised programs is itself a research topic [6, 37, 47]. Failing either demand has a cost. Compilers and hardware assume synchronisation is correct, and the optimisations they apply preserve semantics only when that assumption holds [11, 37]. To avoid these problems entirely, some languages and concurrency paradigms enforce isolation by construction, but they require programs to be (re-)written following their semantics, which is prohibitively expensive for large existing projects based on shared memory.

In this paper, we explore the consequences of fixing the misalignment of synchronisation and isolation for programs written against shared memory. We do so by starting from thread isolation rather than globally shared memory. In our approach, each thread operates on a private view of memory, and synchronisation operations (such as unlock) are reinterpreted to provide both explicit ordering and explicit communication of shared data. By explicit communication, we mean that a thread's synchronisation points are the only places where its private updates are communicated outwards and other threads' updates inwards.

This memory model has several important properties. First, isolation means that data races in the shared-memory sense are impossible by construction. Explicit communication means that a program's synchronisation dictates precisely where updates from different threads are brought together, and any conflicts (such as unsynchronised concurrent writes to the same variables) are detected there. Second, explicit communication exposes the design decisions of what data is shared with which threads, what we call the communication topology, and what constitutes a conflict. Finally, extending existing program synchronisation ordering to provide explicit communication means that programs need no changes and correctly synchronised programs retain their semantics.

We call this memory model Sync-as-Share. For concreteness, we instantiate Sync-as-Share for Java by reinterpreting the synchronisation actions of the Java Memory Model (JMM), i.e., monitors, volatile fields, and thread start and join. In this paper:

  • we introduce Sync-as-Share and explore the consequences of defaulting to thread isolation with synchronisation as explicit communication (§2);
  • we explore realisations for two communication topologies (§3);
  • we formalise the semantics of the two topologies together with a simplified shared-memory baseline (§4);
  • we mechanise our formalism in Rocq [1] and show that correctly synchronised programs under Sync-as-Share present the same behaviour as under shared memory (§5);
  • we discuss some of the design choices inherent to Sync-as-Share (§6).

Our aim in this paper is to design a memory model built on isolation and communication, rather than on the ordering of accesses to shared memory. The motivation is to enable a better understanding of, and avoidance of, data races, while providing backwards compatibility for correctly synchronised programs through the reuse of their existing synchronisation operations. In particular, this paper does not address implementation and optimisation of the model, which we leave for future work. While we understand that the most direct implementation of Sync-as-Share would have significant overhead, we encourage the reader to consider this akin to the first introduction of other quality-of-code ideas, such as garbage collection, whose overheads have been successfully addressed over time. In addition, while our design is largely language agnostic, we explore our model in the context of Java, and explicitly leave discussions of how it would interact with other languages' memory models for later work.

References (20)