You have an open Iterator in your for loop (plus the extra Iterator it), and you're adding values in createProjectile. You need to either make both blocks synchronized on shots, or (my recommendation) make a copy of shots to do your drawing from:List<Projectile> shotsToPaint;synchronized(shots) { shotsToPaint = [`ImmutableList`][1].copyOf(shots); }并在 createProjectile 中应用适当的同步.根据它对性能的敏感程度,您可以在 shots 上同步整个方法或在 shots 上同步,检查大小,创建新的 Projectile 在一个未同步的块中,然后同步重新检查列表大小并添加.and apply appropriate synchronization in createProjectile. Depending on how performance-sensitive it is, you can either synchronize the whole method on shots or synchronize on shots, check the size, create the new Projectile in an unsynchronized block, and then synchronize to recheck the list size and add. 这篇关于TryCatch ConcurrentModificationException 捕获`30% 的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-26 07:00