@[email protected]M to Science [email protected]English • 9 months agoExplain yourselves, comp sci.mander.xyzmessage-square71fedilinkarrow-up1513
arrow-up1513imageExplain yourselves, comp sci.mander.xyz@[email protected]M to Science [email protected]English • 9 months agomessage-square71fedilink
minus-squareunalivejoylinkfedilinkEnglish1•9 months agoThread safe as in it raises an exception instead of breaking your list.
minus-square@[email protected]linkfedilinkEnglish1•9 months 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-squareunalivejoylinkfedilinkEnglish1•9 months agoFor everything else, there’s Collections.synchronizedList(new ArrayList<>())
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<>())