Comment on Explain yourselves, comp sci.
ArrayList isn’t thread-safe, though…
Thread safe as in it raises an exception instead of breaking your list.
Only if one thread modifies it while another one is iterating over it, if two threads try to modify the list at once there isn’t any kind of synchronization and it really could break your list.
For everything else, there’s Collections.synchronizedList(new ArrayList<>())
Collections.synchronizedList(new ArrayList<>())
joyjoy@lemm.ee 2 years ago
Thread safe as in it raises an exception instead of breaking your list.
DaPorkchop_@lemmy.ml 2 years ago
Only if one thread modifies it while another one is iterating over it, if two threads try to modify the list at once there isn’t any kind of synchronization and it really could break your list.
joyjoy@lemm.ee 2 years ago
For everything else, there’s
Collections.synchronizedList(new ArrayList<>())