[concurrency-interest] Volatile array and Wait

Inanc Gumus Inanc.Gumus at mccann.com.tr
Wed Oct 19 07:15:56 EDT 2005

So, how to make inter array elements volatile?

-----Original Message-----
From: Jeremy Manson [mailto:jmanson at cs.purdue.edu] 
Sent: Tuesday, October 18, 2005 7:30 AM
To: Vijay
Cc: concurrency-interest at altair.cs.oswego.edu
Subject: Re: [concurrency-interest] Volatile array and Wait

Vijay wrote:
> Question 1) I have an array e.g. volatile long[] a1 = new long[100];
> Now, is the object a1 volatile or every element of array a1 is 
> volatile or both?

The reference is volatile; the elements of the array are not.  Writes to
a1 will be volatile; writes to elements of a1 (a1[0], a1[1]...) will

> Question 2) When we come out of wait state, is it the same thing as 
> entering a synchronized block? Will all the variables be taken from 
> RAM again instead of from the register buffer?

When you wake from wait(), you must reacquire the lock before
proceeding; it therefore has the same semantics as a lock acquisition.

It is a little dangerous to think of these semantics in terms of main
memory and buffers, for reasons that have been discussed in detail on
this list.

Hope that helps!


More information about the Concurrency-interest mailing list