Theoretically, thread-safe code should fix race conditions. Race conditions, as I understand it, occur because two threads attempt to write to the same location at the same time.
However, what about a threading model in which a single thread is designed to write to a location, and several slave/worker threads simply read from the location?
Assuming the value/timing at which they read the data isn't relevant/doesn't hinder the worker thread's outcome, wouldn't this be considered 'thread safe', or am I missing something in my logic?
1) thread1: reader1 checks if not empty - OK 2) thread2: reader2 checks if not empty - OK 3) thread1: reader1 reads - OK 4) thread2: reader2 reads - oops reader1 already emptied queue at step #3