---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 16 Edition"
java_version: 16
chapter: "Chapter 17. Threads and Locks"
section: "17.4.4"
heading: "17.4.4. Synchronization Order"
parent: "17.4. Memory Model"
source: https://docs.oracle.com/javase/specs/jls/se16/html/jls-17.html#jls-17.4.4
id: "17.4.4"
url: https://jvm.obfuscated.software/jls/se16/17.4.4.html
raw: https://jvm.obfuscated.software/jls/se16/17.4.4.md
---

# 17.4.4. Synchronization Order

Every execution has a *synchronization order*. A synchronization order is a total order over all of the synchronization actions of an execution. For each thread *t*, the synchronization order of the synchronization actions ([§17.4.2](17.4.2.md)) in *t* is consistent with the program order ([§17.4.3](17.4.3.md)) of *t*.

Synchronization actions induce the *synchronized-with* relation on actions, defined as follows:

- An unlock action on monitor *m* *synchronizes-with* all subsequent lock actions on *m* (where "subsequent" is defined according to the synchronization order).

- A write to a volatile variable *v* ([§8.3.1.4](8.3.1.4.md)) *synchronizes-with* all subsequent reads of *v* by any thread (where "subsequent" is defined according to the synchronization order).

- An action that starts a thread *synchronizes-with* the first action in the thread it starts.

- The write of the default value (zero, `false`, or `null`) to each variable *synchronizes-with* the first action in every thread.

  Although it may seem a little strange to write a default value to a variable before the object containing the variable is allocated, conceptually every object is created at the start of the program with its default initialized values.

- The final action in a thread `T1` *synchronizes-with* any action in another thread `T2` that detects that `T1` has terminated.

  `T2` may accomplish this by calling `T1.isAlive()` or `T1.join()`.

- If thread `T1` interrupts thread `T2`, the interrupt by `T1` *synchronizes-with* any point where any other thread (including `T2`) determines that `T2` has been interrupted (by having an `InterruptedException` thrown or by invoking `Thread.interrupted` or `Thread.isInterrupted`).

The source of a *synchronizes-with* edge is called a *release*, and the destination is called an *acquire*.
