_cancelled
must be volatile
. (if you don't choose to lock)
If one thread changes the value of _cancelled
, other threads might not see the updated result.
Also, I think the read/write operations of _cancelled
are atomic:
Section 12.6.6 of the CLI spec states:"A conforming CLI shall guarantee that read and write access to properly aligned memory locations no larger than the native word size is atomic when all the write accesses to a location are the same size."