[concurrency-interest] Traversal and removing elements from ConcurrentskipListSet

Michael Kuhlmann concurrency at kuli.org
Wed May 17 03:29:39 EDT 2017

And in addition to Martin's comments, which already named the issue,
this is not what I meant with the iterator:

Am 17.05.2017 um 04:36 schrieb Dileep Mandapam:
>             /*Iterator<MyBug> iterator = concurrentSkipListSet.iterator();
>             while (iterator.hasNext()) {
>                 MyBug bug = iterator.next();
>                 if (flag) {
>                     boolean remove = concurrentSkipListSet.remove(bug);
>                     System.out.println("removed = "+ bug + " result = "+
> remove);
>                 }
>                 flag = !flag;
>             }*/

Of course you should call remove() on the iterator itself, otherwise
that part of your code would do nothing different than the previous.

Anyway, fix your comparator, and do something with your main() method,
whatever you're expecting - currently it's stuck in an endless loop,
totally independent of your list instance and whatever you do with it.


More information about the Concurrency-interest mailing list