Fixed a race condition at thread initialisation in Windows.