Whats the new JMM (JSR-133) all about?
Apparently the rules that govern the java memory these days have been changed. A brief list of the new rules:
- Volatile read/write instructions cannot be reordered with other instructions
- Synchronized blocks cannot be executed out of sequence with each other
- Writes that initialize final fields will not be reordered with operations following the freeze
- Every entry into a synchronised blocks trigger a flush of working memory so that all subsequent calls goto main memory
- Every exit out of synchronised blocks trigger a write of working memory to main memory
- All actions in a thread t1 should happen before any other thread (t2 say), successfully returns from a
Thread.join()on thread t1.