Ted Baker wrote:
By the way, this is one (the main?) reason why the transition from normal to cancelled is one-way, and the effect of cancellation is not necessarily immediate. That way you can maintain consistency without a lock on the bit that says whether a thread is cancelled. Another thread can set the cancellation bit and the target thread some time later notices that the bit is set. Since the bit is never reset, there is no race condition.
This is the first justification I've seen for Ulrich's position. Can you elaborate on how allowing us to reset the cancelled bit could lead to a race condition?
Jason