JMM defines rules for how threads interact through memory. It provides formal 'Happens-Before' guarantees to ensure that a write in one thread is correctly visible to a read in another thread. Without JMM, compilers/CPUs could reorder code in ways that completely break multithreaded logic.
JMM is the CONTRACT between the programmer and the JVM. It guarantees that if you follow the rules (synchronization, volatile), your multithreaded code will work correctly across all JVM implementations and CPUs.
What does 'Happens-Before' mean? Provide real examples of happens-before relationships.