David M. Lloyd wrote:
On 05/14/2008 10:55 AM, Emmanuel Lecharny wrote:
Sangjin Lee wrote:
Hmm... Could you share a simple example of a non-volatile variable that
respects the volatile contract?

any boolean.

This is incorrect. Changes made to a boolean that is not volatile may never become visible in another thread.
Sorry, I didn't read the question carefully. You are right David.

What I meant is that a volatile boolean is clearly protected, as you can't apply simple opration like ++ or -- on it. I don't know about :
volatile boolean b = Boolean.TRUE;
...
b = !b; // Might fails if used in a concurrent portion of the code.
...

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to