is there any better option than Collections.synchronizedList(mutableListOf()) in stdlib or in libraries ?
i would feel a lot safer if i knew that i do not have any nasty ConcurrentCoModificationExceptions waiting for me due to forgetting to synchronize() on the list somewhere
g
gildor
09/03/2018, 1:19 PM
what is your use case for this?
Usually with coroutines you can replace such mutable structure with actor that allows synchronise operations to mutable state
or use some another approach
b
BMG
09/04/2018, 6:49 AM
@Nikky You might find
CopyOnWriteArrayList
Useful. But it is costly if you are doing a lot of mutations.
n
Nikky
09/04/2018, 10:29 AM
Well.. I am iterating over, filtering, calling contains and adding to a MutableList<String>
I know how to use channels to synchronize adding.. I am not too sure about the rest
g
gildor
09/05/2018, 4:15 PM
You can use actors, it allows you to encapsulate state and safely update it (actor by default process commands sequentially)