Thread Safety Issue: Race Conditions