[concurrency-interest] Mixing volatile and synchronized together...

Tim Peierls tim at peierls.net
Fri Oct 14 11:38:27 EDT 2005


Ryan LeCompte wrote:
> I know that there really isn’t a need to do this, but I was wondering if 
> In other words, there is no harm in using a volatile variable in a 
> synchronized method or block, right?

Right, no harm. Depending on the situation, one or the other might be superfluous, but there is 
nothing unsafe about accessing a volatile in a synchronized block or method.

--tim





More information about the Concurrency-interest mailing list