[concurrency-interest] Volatile array and Wait
Inanc.Gumus at mccann.com.tr
Wed Oct 19 07:15:56 EDT 2005
So, how to make inter array elements volatile?
From: Jeremy Manson [mailto:jmanson at cs.purdue.edu]
Sent: Tuesday, October 18, 2005 7:30 AM
Cc: concurrency-interest at altair.cs.oswego.edu
Subject: Re: [concurrency-interest] Volatile array and Wait
> Question 1) I have an array e.g. volatile long a1 = new long;
> 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, a1...) 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
Hope that helps!
More information about the Concurrency-interest