Evading race conditions