jakesmith/HPCC-Platform — comment on commit 7d2e17bb2657956e225be63eb2d16af26b94e128
File: system/jlib/jthread.cpp line 544
By jakesmith:

I am leaving the state in running..
I don't want to change state to ready, if running, if it was already joining, the 2nd cas test would be ok to drop into, but can't test that first, that would leave a window where fails (!joining) and becomes so after test here.
So order :
if (!atomic_cas(&state, s_ready, s_running))
if (atomic_cas(&state, s_ready, s_joining))

is correct I think.

And if exception, I always want to signal (left as running) - so join will pick up once it has CAS'd from running->joining.