Is volatility or context lock always on?

Initially, I thought that a volatile variable is better than a synchronized keyword, since it is not related to BLOCKING or CONTEXT SWITCHING. But after reading this , I am now confused.

Is volatile implemented in a non-blocking approach using low-level atomic locks or not?

+5
source share
5 answers

Is volatile implemented in a non-blocking approach using low-level atomic locks or not?

A volatile implementation differs between each processor, but it is non-blocking loading / storing a field - it is usually implemented through memory gaps, but can also be controlled using cache-coherent protocols.

. Volatile vs Synchronized flow, - . Volatile , , , , , .

+5

volatile ?

volatile . "". volatile -, . , .

+5

, volatile .

, , BLOCKING CONTEXT SWITCHING.

, . volatile volatile , , , .

, volatile , / . . , , , . .

(synchronized) .

, , , , , volatile, synchronized, .

+3

Volatile Java , JVM. Volatile, , , . JVM , .

+1

BLOCKING , volatile, . , , " " ( ).

, volatile , , / , , , ( / JVM), .

volatile , .

0
source

All Articles