If two threads call executeFront() at the same time, it's possible that none of them executes any task, although there are permits available, and one of the threads just added a task in the queue. This scenario causes random initial state transfer timeouts in the testsuite: T1: continueTaskInBackground(): queue = empty, permits = 0 T1: backgroundTaskFinished() T1: = semaphore.release(): queue = empty, permits = 1 T1: = executeFront() T1: == semaphore.acquire() -> true: queue = empty, permits = 0 T2: == queue.poll() -> null T2: submit(task) T2: = executeFront() T2: == semaphore.acquire() -> false T2: return without executing any task T1: return without executing any task