Java:流中的ConcurrentLinkedQueue行为,其中删除了某些元素

时间:2015-10-23 08:06:15

标签: java java-8

如果我有ConcurrentLinkedQueue,使用流来删除同一列表中的某些元素是否安全?

例如:

Queue<MyThread> threadList = new ConcurrentLinkedQueue<MyThread>();
//concurrently add and execute some threads to this list

//then we call this concurrently to remove done threads from the thread list
threadList.stream().filter( MyThread::isDone ).forEach( threadList::remove );

0 个答案:

没有答案