sbyrne
03/31/2020, 2:02 PMprivate val done:MutableSet<T> = mutableSetOf()
in a class. Method a
starts a thread which calls method b
, which has synchronized(done)
. I intermittently get an NPE on synchronize(done)
. I moved the private val done
declaration from between a
and b
to above a
and that seems to have fixed it. Am I crazy?Zach Klippenstein (he/him) [MOD]
03/31/2020, 5:27 PMfun a() = thread { synchronized(done) { … } }
private val done = …
fun b() = …
But this doesn't:
private val done = …
fun a() = thread { synchronized(done) { … } }
fun b() = …
Where/when are you calling a?sbyrne
03/31/2020, 5:41 PMsbyrne
03/31/2020, 5:42 PMZach Klippenstein (he/him) [MOD]
03/31/2020, 5:47 PMZach Klippenstein (he/him) [MOD]
03/31/2020, 5:48 PM