D
D
Drunya20182018-11-07 22:23:31
Java
Drunya2018, 2018-11-07 22:23:31

Java. How to fix ConcurrentModificationException in this code?

This code throws java.util.ConcurrentModificationException when creating a large number of threads. And in the 84th line, sometimes there is an output beyond the aisles of the array (-1). If it's not difficult, write what's wrong in the code...
https://github.com/Drunya2/BattleShip/blob/master/...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2018-11-08
@EugeneP2

At a minimum, using a non-thread-safe ArrayList is not correct when multithreading, which is why you get the ConcurrentModificationException. Here is a nice overview of Concurrent Collections

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question