4 ms·
I suppose it depends on how you define "race condition", but what I mean is that there's literally a race between the executing code and the timeout handler. Ei
by skybrian 10y ago
I suppose it depends on how you define "race condition", but what I mean is that there's literally a race between the executing code and the timeout handler. Either one can win. The output is non-deterministic; it depends on scheduling.
Or to put it another way, adding a timeout makes any function's output non-deterministic, no matter how "pure" it is. It's only deterministic if you wait as long as necessary for it to finish.