Adds a counter uninit_thread_count which is incremented in UNIX just prior to a new thread being created. Synchall will keep looping while this counter is positive, ensuring we avoid races with threads created but not yet initialized during a detach synchall which then use DR resources after detach, causing crashes.
Leaves the counter at 0 on Windows where we can't distinguish external vs internal thread creation, but Windows does have the init_apc_go_native flag which eliminates some races.
Adds a test. To more reliably hit the race (about half the time) I locally added a 50ms sleep at the top of dynamo_thread_init().
Fixes #2600 (closed)