|
|
Werner Van Belle wrote:
> Kermit Mei wrote:
>> Hello all!
>> In embedded C++ code, the keyword "volatile" can prevent the complier
>> from optimizing it.
>> But, in mutil-thread programming, what dose it mean?
>> Look the following code as an example, I wish you would like to explain
>> it for me.
>
> It means that any thread accessing the variable should read it again and
> not rely on some form of caching. E.g. If you want to wait until the
> thread stopped you can write something like
>
> while (thread->stopped) sleep(1);
Reading my own post, I meant:
while (!thread->stopped) sleep(1);
it does however make no difference in the explanation.
--
Dr. Werner Van Belle
http://werner.yellowcouch.org/
|
|