Re: Why can't I start a thread twice?
- From: "Chuan C." <spam@xxxxxxx>
- Date: Sat, 02 May 2009 21:57:49 +0200
Hi Peter
Peter Duniho wrote:
On Sat, 02 May 2009 12:34:53 -0700, Chuan C. <spam@xxxxxxx> wrote:
[...]
Furthermore, the code you posted doesn't even bother to make "go"
volatile,
Could you explaint that?
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.
Thanks again.
The literature I was following did not mention that. I've sent a "bug
report" to the author.
CU
Chuan.
.
- Follow-Ups:
- Re: Why can't I start a thread twice?
- From: Lew
- Re: Why can't I start a thread twice?
- References:
- Why can't I start a thread twice?
- From: Chuan C.
- Re: Why can't I start a thread twice?
- From: Peter Duniho
- Re: Why can't I start a thread twice?
- From: Chuan C.
- Re: Why can't I start a thread twice?
- From: Peter Duniho
- Why can't I start a thread twice?
- Prev by Date: Re: Why can't I start a thread twice?
- Next by Date: Re: micro-benchmarking
- Previous by thread: Re: Why can't I start a thread twice?
- Next by thread: Re: Why can't I start a thread twice?
- Index(es):
Relevant Pages
|