"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
Rob
SCJP 1.4
"I'm not back." - Bill Harding, Twister
Originally posted by Rob Ross:
Here's another quirky issue:
long x = 256;
long y = -1048;
x = y; //not atomic, so not thread safe!
reads and writes of 64 bit quantities are NOT required to be atomic in the spec. You have to either synchronize, or you can use the volitile keyword to force atomicity.
"I'm not back." - Bill Harding, Twister
Originally posted by Jim Yingst:
Well, there are cases where volatile could actually be useful if it were implemented correctly. For example if most threads are interested only in only atomic operations like reading a variable, volatile can be a faster way for them to access the variable, and still safe.
"I'm not back." - Bill Harding, Twister