3 hours ago, MasterPie wrote
*snip*
Thread.Sleep(Thread.CurrentThread.ManagedThreadId * c);
where c is verrrrrry large.
No. Thread.Sleep guarantees that your thread will sleep for at least N milliseconds, but makes no guarantee about when it will wake up after that.
Suppose that c is a million, and we have two threads with managed id 1 and 2.
The first thread sleeps for 1 * one million milliseconds. The second sleeps for 2 * one million milliseconds.
But in your code there is no guarantee that the first thread will start before 2.1 million milliseconds after the call. And consequently you still have a race-condition.