In order to make sure that changes to queue and changes to perClientBacklog happen atomically, I wrapped their modifications in synchronized(this) blocks. I didn't want to use a blocking poll while holding the mutex.