lock on bool when access via multiple threads
Posted on 2008-10-30
I have two threads.
Currently I check on a bool to determine whether one of the threads should stop work. The bool is set from the other thread. Do I need to lock around the bool? I presumed I would, but collegues believe I may not have to? Another collegue mentioned setting the bool to volatile, so it's not cached? I appreciate if anyone could suggest the correct action.