The Java memory model
describes how threads
in the Java programming language
interact through memory. Together with the description of single-threaded execution of code, the memory model provides the semantics
of the Java programming language.
The original Java memory model, developed in 1995, was widely perceived as broken, preventing many runtime optimizations and not providing strong enough guarantees for code safety. It was updated through the Java Community Process
, as Java Specification Request 133 (JSR-133), which took effect in 2004
, for Tiger
The Java programming language
and platform provide thread
capabilities. Synchronization between threads is notoriously difficult for developers; this difficulty is compounded because Java applications can run on a wide range of processors
and operating systems
. To be able to draw conclusions about a program's behavior, Java's designers decided they had to clearly define possible behaviors of all Java programs.
On modern platforms, code is frequently not executed in the order it was written. It is reordered by the compiler, the processor and the memory subsystem to achieve maximum performance. On multiprocessor
architectures, individual processors may have their own local caches that are out of sync with main memory. It is generally undesirable to require threads to remain perfectly in sync with one another because this would be too costly from a performance point of... Read More