How does volatile actually work?

Posted by FredOverflow on Stack Overflow See other posts from Stack Overflow or by FredOverflow
Published on 2010-04-22T20:58:44Z Indexed on 2010/04/23 14:53 UTC
Read the original article Hit count: 312

Filed under:
|
|

Marking a variable as volatile in Java ensures that every thread sees the value that was last written to it instead of some stale value. I was wondering how this is actually achieved. Does the JVM emit special instructions that flush the CPU cashes or something?

© Stack Overflow or respective owner

Related posts about java

Related posts about volatile