By the way, I'm afraid using a sleep to deal with synchronization problems is only postponing the problem. If the CPU pauses one thread longer than your sleep you get the data race problem again. In everything I've read and done the only way is to properly synchronize.