angarron
03/19/2020, 4:34 PM@Synchronized
fun notify(updates: Set<UpdateSource>) {
Log.d("findme", "notify START: $updates")
observers.forEach { observer ->
/* stuff */
}
Log.d("findme", "notify END")
}
@Synchronized
private fun disconnect(observer: Observer) {
Log.d("findme", "disconnect START")
observers.remove(observer)
Log.d("findme", "disconnect END")
}
and I see these logs:
2020-03-19 09:25:16.545 21962-22072/com.discord.debug D/findme: notify START: [com.discord.stores.StoreUser@c7528b5, com.discord.stores.StoreUser$Companion$UsersUpdate$1@91882e5]
2020-03-19 09:25:16.548 21962-22072/com.discord.debug D/findme: disconnect START
2020-03-19 09:25:16.548 21962-22072/com.discord.debug D/findme: disconnect END
Can anyone explain how it's possible that "notify END" never prints? if that forEach
was hanging, I would expect a hung thread, but we are able to enter the disconnect
method -- which means that I feel like I'm misunderstanding something about @Synchronized
araqnid
03/19/2020, 4:42 PMangarron
03/19/2020, 4:45 PMpedro
03/19/2020, 4:45 PMnotify
called disconnect
.
You never saw the “END” log because the exception was thrown. The stacktrace would be something like 1. notify 2. disconnect so the notify method had not finished yet