1// THIS WILL SEND AN INTERRUPT TO ALL MATCHING THREADS
2Thread.getAllStackTraces().keySet().each() {
3 t -> if (t.getName().contains("PATTERN") ) { t.interrupt(); }
4}
5
6// THIS WILL FORCE-STOP ALL MATCHING THREADS
7// May be required for recursive loops
8Thread.getAllStackTraces().keySet().each() {
9 t -> if (t.getName().contains("PATTERN") ) { t.stop(); }
10}