4 ms·
Very cool but will the threads necessarily wake up deterministically? One may wake up before another but not get cpu before it correct? (forgive me if I'm misun
by humbleharbinger 3y ago
Very cool but will the threads necessarily wake up deterministically? One may wake up before another but not get cpu before it correct? (forgive me if I'm misunderstanding the code)
- colanderman 3y agoYes, the algorithm suffers from a race condition. Time is not a synchronization primitive.
- greiskul 3y agoYup. If we are being pedantic, and I am sure the author of this loves being pedantic, any number of factors could cause this algorithm to be incorrect. Put it in a slow enough cpu for instance, and it will output the wrong answer. And correctness is the single most important part of an algorithm. We can do any problem in constant time if we don't mind our answers are not correct.
- MPSimmons 3y agoreturn(4)