{"id":4238,"date":"2019-05-13T16:50:49","date_gmt":"2019-05-13T08:50:49","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=4238"},"modified":"2019-05-13T16:50:49","modified_gmt":"2019-05-13T08:50:49","slug":"concurrentmodificationexception-%e5%b9%b6%e5%8f%91%e4%bf%ae%e6%94%b9%e5%bc%82%e5%b8%b8%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4238","title":{"rendered":"ConcurrentModificationException \u5e76\u53d1\u4fee\u6539\u5f02\u5e38\u95ee\u9898\u89e3\u51b3"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u524d\u9762\u7684\u90a3\u7bc7\u6587\u7ae0\u6211\u5df2\u7ecf\u9884\u544a\u8fc7\u4e86\uff0c\u4eca\u5929\u8981\u5199\u4e00\u4e2a\u5e76\u53d1\u4fee\u6539\u5f02\u5e38\u7684\u6848\u4f8b\u3002\u5728 MySQL \u4e2d\uff0c\u6211\u89e3\u91ca\u4e86\u4e00\u4e2a\u5168\u5c40\u9501\uff0c\u7981\u6b62\u4fee\u6539\u6570\u636e\u7684\u53d1\u751f\u3002\u4f46\u662f\u5728 java \u4e2d\u4f60\u53ef\u80fd\u6216\u591a\u6216\u5c11\u7684\u9047\u5230\u8fc7 ConcurrentModificationException \u95ee\u9898\uff0c\u8fd9\u5c31\u662f\u5e76\u53d1\u4fee\u6539\u5bfc\u81f4\u7684\u5f02\u5e38\u95ee\u9898\uff0c\u4eca\u5929\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u4e3a\u4ec0\u4e48\u4f1a\u4ea7\u751f\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u5e38\uff0c\u6211\u4eec\u5728\u904d\u5386 Java \u4e2d\u7684\u96c6\u5408\u65f6\uff0c\u5982\u679c\u4e0d\u6ce8\u610f\u5e76\u53d1\u4fee\u6539\u3002\u90a3\u4e48\u7a0b\u5e8f\u5458\u5f02\u5e38\uff0c\u53d1\u751f\u751f\u4ea7\u95ee\u9898\u662f\u663e\u800c\u6613\u89c1\u7684\u3002\u770b\u4e0b\u9762\u4e00\u6bb5\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();\nlist.add(520);\nIterator&lt;Integer&gt; iterator = list.iterator();\nwhile(iterator.hasNext()){\n    Integer num = iterator.next();\n    if(520 == num){\n        list.remove(num);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u5c31\u56de\u51fa\u73b0\u4e0b\u9762\u7684\u9519\u8bef\uff1ajava.util.ConcurrentModificationException\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g2zs3pc0xhj20l6042gmy.jpg\" alt=\"\" \/><figcaption>java.util.ConcurrentModificationException<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u8ffd\u8e2a\u4e0a\u9762\u7684\u9519\u8bef\u4ee3\u7801\uff0c\u4f60\u4f1a\u53d1\u73b0\u6700\u7ec8\u7684\u5f02\u5e38\u662f\u53d1\u751f\u5728 checkForComodification \u65b9\u6cd5\u4e2d\u3002\u6839\u636e\u65b9\u6cd5\u7b7e\u540d\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u68c0\u67e5\u662f\u5426\u6709\u4fee\u6539\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u5177\u4f53\u7684\u6e90\u7801\uff0c\u4f60\u4f1a\u53d1\u73b0\u5728 checkForComodification \u65b9\u6cd5\u4e2d\u6709\u4e00\u4e2a\u5224\u65ad\uff0c\u96c6\u5408\u6dfb\u52a0\u5143\u7d20\u3001\u5220\u9664\u5143\u7d20\u7684\u6b21\u6570 modCount \u5982\u679c\u4e0d\u7b49\u4e8e\u96c6\u5408\u7684\u9884\u671f\u7684\u4fee\u6539\u6b21\u6570 expectedModCount \u5c31\u56de\u629b\u51fa ConcurrentModificationException \u5f02\u5e38\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g2zs50ppbwj20f802ijrt.jpg\" alt=\"\" \/><figcaption>ConcurrentModificationException<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u90a3\u4e48\u8be5\u5982\u4f55\u907f\u514d\u8fd9\u7c7b\u95ee\u9898\u5462\uff1f\u7b54\u6848\u5728\u300a\u963f\u91cc\u5df4\u5df4 Java \u5f00\u53d1\u89c4\u5219\u300b\u4e2d\u5df2\u7ecf\u6709\u4e86\u5f3a\u5236\u6027\u7684\u89c4\u5b9a\uff0c\u4f30\u8ba1\u5f88\u591a\u4eba\u6709\u8fd9\u4e2a\u8d44\u6599\uff0c\u4f46\u662f\u4ece\u6765\u6ca1\u770b\u8fc7\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g2zs67xecrj20pu0h740a.jpg\" alt=\"\" \/><figcaption>\u963f\u91cc\u5df4\u5df4 Java \u5f00\u53d1\u89c4\u5219<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u6240\u5e2e\u52a9\u3002\u5e0c\u671b\u5927\u5bb6\u591a\u5b66\u4e60\uff0c\u591a\u8bfb\u4e66\uff0c\u591a\u770b\u6e90\u7801\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4238\">ConcurrentModificationException \u5e76\u53d1\u4fee\u6539\u5f02\u5e38\u95ee\u9898\u89e3\u51b3<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u524d\u9762\u7684\u90a3\u7bc7\u6587\u7ae0\u6211\u5df2\u7ecf\u9884\u544a\u8fc7\u4e86\uff0c\u4eca\u5929\u8981\u5199\u4e00\u4e2a\u5e76\u53d1\u4fee\u6539\u5f02\u5e38\u7684\u6848\u4f8b\u3002\u5728 MySQL \u4e2d\uff0c\u6211\u89e3\u91ca\u4e86\u4e00\u4e2a\u5168\u5c40\u9501\uff0c\u7981\u6b62\u4fee\u6539 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[567,1939,568,1147,505],"class_list":["post-4238","post","type-post","status-publish","format-standard","hentry","category-java","tag-java-","tag-1939","tag-568","tag-1147","tag-505"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4238","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4238"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4238\/revisions"}],"predecessor-version":[{"id":4239,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4238\/revisions\/4239"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}