mitigate non-thread-safe race condition

Isn't there still a race condition here, just a somewhat less common one?