Move to crossplatform thread and mutex wrappers