This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: binary compatibility ABI


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]