Currently, the threads that are detaching from or attaching to the runtime
can end up spinning for a long time in the ThreadStore lock for the entire
duration of a GC because the lock is held while GC is in progress. This
problem becomes quite visible when Windows thread pool injects a couple
hundreds of worker threads into a process.
This change fixes the problem by adding an option to the lock to block
spinning threads on the GC event if GC is in progress.
With this change, I see a couple percent improvement on micro-benchmarks.