You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
I was looking for CopyOnWriteArrayList implementation for C# and have ended up here. Please correct your implementation - it is very dangerous if people try to use it for real things. You CANNOT lock on the object you are going to replace in same method. Create some dedicated lock object and synchronize on that. Otherwise, multiple threads can synchronize on different instances of list, losing some updates.
Additionally IndexOf is broken - you need to put reference to list into local variable at very start and use it, rather than iterating through possibly mutating 'this'.
Same for Iterator() - list reference can change between filling both arguments.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I was looking for CopyOnWriteArrayList implementation for C# and have ended up here. Please correct your implementation - it is very dangerous if people try to use it for real things. You CANNOT lock on the object you are going to replace in same method. Create some dedicated lock object and synchronize on that. Otherwise, multiple threads can synchronize on different instances of list, losing some updates.
Additionally IndexOf is broken - you need to put reference to list into local variable at very start and use it, rather than iterating through possibly mutating 'this'.
Same for Iterator() - list reference can change between filling both arguments.
The text was updated successfully, but these errors were encountered: