[threads] If shutting_down, don't create new thread, kill current thread (#32968)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Fri, 13 Mar 2020 14:45:03 +0000 (10:45 -0400)
committerGitHub <noreply@github.com>
Fri, 13 Mar 2020 14:45:03 +0000 (10:45 -0400)
commit19d5b8ca832380e10bb4618d691139c8572152cd
treeea5189428304f9479203e4c515e49443e0fd522a
parentd69c8525c508b32fdad84a2e15bef94a48153ea0
[threads] If shutting_down, don't create new thread, kill current thread (#32968)

If the runtime is shutting down, instead of creating a new thread, or throwing
an exception on the current thread, just shut down the current thread.

This takes advantage of `mono_threads_set_shutting_down`'s behavior that if you
call it after shutdown is already started, it will suspend, detach and exit
from the current thread.

Fixes https://github.com/dotnet/runtime/issues/31842
src/mono/mono/metadata/threads.c