我需要中断并从列表中删除线程,给定片段抛出一个ConcurrentModificationException
threads //array list containing threads
.stream()
.filter(thread -> thread.getName().equalsIgnoreCase(threadName))
.forEach(thread -> {
thread.interrupt(); threads.remove(thread); // this cause a java.util.ConcurrentModificationException
thread.interrupt();; // this works fine
});