A simple non-reentrant lock used for exclusion when managing
queues and workers. We use a custom lock so that we can readily
probe lock state in constructions that check among alternative
actions. The lock is normally only very briefly held, and
sometimes treated as a spinlock, but other usages block to
reduce overall contention in those cases where locked code
bodies perform allocation/resizing.
Code and comments borrowed from Doug Lea's FJPool.