I have multiple threads constantly iterating through an ArrayList
called "clients".
When they disconnect I want to remove a single client from the list but I am aware that it could cause a concurrent modification exception.
Should I surround all usage of the ArrayList
with the Synchronized
block or is that not a good idea?
Also can the ArrayList
be read by multiple threads without a problem?
Thanks,
(The client list is constantly iterated by the UDP thread that sends data to all the clients)