Skip to content
Advertisement

Tag: java-memory-model

Java memory model and local variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question

volatile with release/acquire semantics

Since Java 5, the volatile keyword has release/acquire semantics to make side-effects visible to other threads (including assignments to non-volatile variables!). Take these two variables, for example: Note that i is a regular, non-volatile variable. Imagine thread 1 executing the following statements: At some later point in time, thread 2 executes the following statements: According to the Java memory model,

Advertisement