Re: Why can't I start a thread twice?
Peter Duniho wrote:
Since the variable isn't marked as "volatile", the compiler and run-time
are both free to make optimizations to access to the variable, including
caching its value locally. Without "volatile" or some other
synchronization mechanism, there's no guarantee that just because one
thread set the variable to a particular value, that another thread will
ever see that particular value.
Sometimes it will work. In fact, often times it will work. But without
a guarantee, the code is buggy regardless.
Chuan C. wrote:
The literature I was following did not mention that. I've sent a "bug
report" to the author.
Given that that is one of the most fundamental facts of multi-threaded
programming and one of the most common sources of bugs in multi-threaded code,
I'm guessing the author really must not know what they're talking about and
that a mere bug report will not do much to fix what must certainly be
fundamental flaws in their explanations.
Can you tell us what "literature" you were following? Is there a direct link
to it on line? Who's the author?
--
Lew