Concurrent Modification Exception : adding to an ArrayList

前端 未结 10 1047
醉梦人生
醉梦人生 2020-11-22 10:53

The problem occurs at

Element element = it.next();

And this code which contains that line, is inside of an OnTouchEvent

10条回答
  •  醉话见心
    2020-11-22 11:34

    Using Iterators also fixes concurrency problems, like this:

    Iterator it = iterator.next().iterator();
    while (it.hasNext()) {
        it.remove();
    }
    
        

    提交回复
    热议问题