Race Condition Scenario
A race condition occurs if the effect of multiple threads on
shared data depends on the order in which the threads are scheduled.
- First thread calls add and executes
elements[tail] = anObject;
- First thread at end of time slice
- Second thread calls add and executes
elements[tail] = anObject;
tail++;
- Second thread at end of time slice
- First thread executes
tail++;