I must say that it’s probably a bad pattern, but in my sandbox I created an interface that call a background service (that fires a thread and keep it live) every time I click a button.
This is good, cause I can create a chaos situation and found out how the environment will deal with this.
But, otherwise, I’m facing a problem: How can I get all thread currently running and kill them all. Calling GB or something.
I assume that you don’t want a list of all running threads- you want a list of running threads that you started via some particular mechanism, right?
If that’s the case, you can do something like this where you start those threads:
Now, assuming that you want to kill those threads with extreme prejudice– that is, you want them dead, now, and you don’t care about knock-on effects of leaving work half-done, you can do: