Fixed a rare race condition.

The worker thread would unlock the lock of the work queues and then go
to sleep. However, this operation wasn't atomic, so another thread could
add work for it and then try to notify a thread. It was assumed that
when no thread could be notified all of them were busy. In fact, what
happened was that the threads had unlocked the mutex but with the
purpose of going to sleep instead of being about to switch to another
coroutine.