/** * First interrupts all the threads in the specified list and then waits until they have terminated. * If any have not terminated after a short delay (1000 ms), false is returned. */ public static boolean stopThreads(List<Thread> threads) { boolean status = true; threads.forEach(t -> t.interrupt()); for (Thread t : threads) { status = joinThread(t) && status; } return status; }