Subj : Re: volatile or mutex To : comp.programming.threads From : Scott McPhillips [MVP] Date : Wed May 11 2005 10:13 pm marri wrote: > Do we need to use volatile or a mutex to synchronize read/write of an > integer variable??. > > Found that people defile volatile for a boolean variable and > synchronize using mutex for integer variables is there any good > reason?? > > Thanks in advance > volatile has nothing to do with synchronization. It only assures that the compiler will actually read the variable's memory when you tell it to. If the read is done without synchronization then under some circumstances on some machines the result will be corrupt. -- Scott McPhillips [VC++ MVP] .