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

# 17.4.2. Actions

An *inter-thread action* is an action performed by one thread that can be detected or directly influenced by another thread. There are several kinds of inter-thread action that a program may perform:

- *Read* (normal, or non-volatile). Reading a variable.

- *Write* (normal, or non-volatile). Writing a variable.

- *Synchronization actions*, which are:

  - *Volatile read*. A volatile read of a variable.
  - *Volatile write*. A volatile write of a variable.
  - *Lock*. Locking a monitor
  - *Unlock*. Unlocking a monitor.
  - The (synthetic) first and last action of a thread.
  - Actions that start a thread or detect that a thread has terminated ([§17.4.4](17.4.4.md)).

- *External Actions*. An external action is an action that may be observable outside of an execution, and has a result based on an environment external to the execution.

- *Thread divergence actions* ([§17.4.9](17.4.9.md)). A thread divergence action is only performed by a thread that is in an infinite loop in which no memory, synchronization, or external actions are performed. If a thread performs a thread divergence action, it will be followed by an infinite number of thread divergence actions.

  Thread divergence actions are introduced to model how a thread may cause all other threads to stall and fail to make progress.

This specification is only concerned with inter-thread actions. We do not need to concern ourselves with intra-thread actions (e.g., adding two local variables and storing the result in a third local variable). As previously mentioned, all threads need to obey the correct intra-thread semantics for Java programs. We will usually refer to inter-thread actions more succinctly as simply *actions*.

An action *a* is described by a tuple < *t*, *k*, *v*, *u* >, comprising:

- *t* - the thread performing the action

- *k* - the kind of action

- *v* - the variable or monitor involved in the action.

  For lock actions, *v* is the monitor being locked; for unlock actions, *v* is the monitor being unlocked.

  If the action is a (volatile or non-volatile) read, *v* is the variable being read.

  If the action is a (volatile or non-volatile) write, *v* is the variable being written.

- *u* - an arbitrary unique identifier for the action

An external action tuple contains an additional component, which contains the results of the external action as perceived by the thread performing the action. This may be information as to the success or failure of the action, and any values read by the action.

Parameters to the external action (e.g., which bytes are written to which socket) are not part of the external action tuple. These parameters are set up by other actions within the thread and can be determined by examining the intra-thread semantics. They are not explicitly discussed in the memory model.

In non-terminating executions, not all external actions are observable. Non-terminating executions and observable actions are discussed in [§17.4.9](17.4.9.md).
