Switch over to using `_beginthreadex` to launch threads on windows

Launching threads with `CreateThread` left the CRT per thread state undefined, thus any thread calling into the CRT after creation was destined to have undefined behavior. `_beginthreadex` initializes the per thread state thus preventing that issue.