10.12.2012 Views

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

The Java Language Specification, Third Edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

THREADS AND LOCKS Happens-before Order 17.4.5<br />

Thread 1<br />

X = 1<br />

Lock M1<br />

Y = 1<br />

Unlock M1<br />

Thread 2<br />

Lock M1<br />

r1 = Y<br />

Unlock M1<br />

r2 = X<br />

DRAFT<br />

(b) Thread 2 acquires lock first; Accesses to X not ordered by happens-before<br />

If a program is correctly synchronized, then all executions of the program will<br />

appear to be sequentially consistent (§17.4.3).<br />

565

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!