Maybe doing that check again is faster than doing WaitForSingleObjectEx though?Checking if there is work involves were few instructions (main one is InterlockedCompareAndExchange). WaitForSingleObject involves potential context switch, depends on what OS wants.
But as far as I understand, that means that when multiple threads start the same entry simultaneouslyYes, but they will try to do it and fail. That's why we use InterlockedCompareExchange instruction. It is there to guarantee that only one thread gets job with number N. If other thread also tries to get job with number N it will fail and then retry later with job N+1.