java.util.ConcurrentModificationException

来源:互联网 发布:软件产品质量模型 编辑:程序博客网 时间:2024/05/20 02:55
java.util.ConcurrentModificationException

    java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
    java.util.ArrayList$Itr.next(ArrayList.java:791)
    com.newsms.struts.action.UserMsgRecordAction.sendMsg(UserMsgRecordAction.java:49)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:601)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:441)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)

    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)

报这个错误的原因是:我建了一个collection 然后往里添加数据,当我用for循环遍历collection中的内容后,然后调用了collection的remove() 或者 clear() 方法 ,直接导致出错,而将remove() 或 clear() 方法 放在for循环外面,就不会报错了

原创粉丝点击