Possible Duplicate:
Can a C# thread really cache a value and ignore changes to that value on other threads?
Lets say we have this code:
bool KeepGoing = true;
DataInThread = new Thread(new ThreadStart(DataInThreadMethod));
DataInThread.Start();
//bla bla time goes on
KeepGoing = false;
private void DataInThreadMethod()
{
while (KeepGoing)
{
//Do stuff
}
}
}
Now the idea is that using the boolean is a safe way to terminate the thread however because that boolean exists on the calling thread does that cause any issue?
That boolean is only used on the calling thread to stop the thread so its not like its being used elsewhere