I have a web server so all the incoming requests a...
# getting-started
w
I have a web server so all the incoming requests are their own threads. To simplify, say I just hold a list of numbers,
listOf<Int>
. The incoming requests are the reads but they are complicated reads i.e. I do a lot of logic on that list for each read it's not just a simple
myList[index]
. And every 10 seconds the server updates the list with some external data it grabs. The logs show: 1. read comes in, 2. update starts, 3.
ConcurrentModificationException
so it's definitely a threading issue and I'm trying to figure out how to keep the locking code isolated. I'd prefer not to have to lock on every single read access of this list. Easy to do except with `Iterator`'s, which synchronization doesn't protect against and a lot of the Kotlin
stdlib
uses
Iterable<T>
extension functions (as it should)