Reviewing GC and the Java memory model
We mentioned the JIT compiler as part of the JVM earlier (Figure 2.2). Just to refresh on the JIT compiler, it is responsible for translating the bytecode into system-specific native instructions. These instructions deal with the basic memory and I/O resources available to the program. To properly organize these instructions, the Java platform requires a set of rules that guarantee the program, called bytecode, which must be translated by the JIT compiler at runtime to the same end. Because the Java platform does not use physical memory directly, but rather virtual and cached views, it is very important that the memory management is transparent. The model must provide the required guarantees and is known as the Java Memory Model (JMM).
The JMM
The JMM describes how threads interact with each other through access to allocated memory – the heap (Figure 2.2). The execution of a single-threaded program may seem obvious because the instructions...