binary compatibility ABI
Tom Tromey
tromey@redhat.com
Tue Sep 23 17:10:00 GMT 2003
>>>>> "Bryce" == Bryce McKinlay <bryce@mckinlay.net.nz> writes:
Bryce> Actually, does the new Java memory model make any guarantees
Bryce> here?
Bryce> class X
Bryce> {
Bryce> static int a;
Bryce> void m()
Bryce> {
Bryce> System.out.println(Y.s);
Bryce> System.out.println(X.a);
Bryce> }
Bryce> }
Bryce> class Y
Bryce> {
Bryce> static int s;
Bryce> static
Bryce> {
Bryce> Y.s = 55;
Bryce> X.a = 25;
Bryce> }
Bryce> }
Bryce> Presumably, the first println is guaranteed to print '55'? But is the
Bryce> second println guaranteed to print '25'?
Yes, I think so, because class initialization acquires a lock, and
releasing the lock forces memory synchronization.
Tom
More information about the Java
mailing list