fossilesque@mander.xyzM to Science Memes@mander.xyzEnglish · 2 years agoExplain yourselves, comp sci.mander.xyzimagemessage-square41fedilinkarrow-up1350arrow-down111
arrow-up1339arrow-down1imageExplain yourselves, comp sci.mander.xyzfossilesque@mander.xyzM to Science Memes@mander.xyzEnglish · 2 years agomessage-square41fedilink
minus-squareDaPorkchop_@lemmy.mllinkfedilinkEnglisharrow-up1·2 years agoOnly 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.
minus-squareunalivejoy@lemm.eelinkfedilinkEnglisharrow-up1·2 years agoFor everything else, there’s Collections.synchronizedList(new ArrayList<>())
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<>())