
















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















































COMP 522 Lecture 12 13 October 2008
Why a Memory Model for Java?
Example: Double-Checked Locking class Foo { private Helper helper = null ; public Helper getHelper() { if (helper == null ) { synchronized ( this ) { if (helper == null ) { helper = new Helper(); } } } return helper; } ... }
Fixing Double-Checked Locking? class Foo { private Helper helper = null; public Helper getHelper() { if (helper == null ) { Helper h; synchronized(this) { h = helper; if (h == null ) synchronized (this) { h = new Helper(); } // release inner synchronization lock helper = h; } } return helper; } ... } still broken: helper=h may be moved into inner synchronized block & executed before initialization is complete
Today’s Paper: Not The First JMM ... Original Memory Model for Java (JMM 1.0)
JMM 1.0 “Fatally Flawed” [Pugh, CPE00]
Why Not Sequential Consistency?
Java Memory Model
Java Memory Model Benefits
Terminology I
Happens-Before Model
Happens-Before Model
Happens-Before Model
Happens-Before Model