Centralize the thread ready queue logic.

This makes it slower for now, but should make it easier to optimize correctly.
Keep track of the first thread per queue.

Makes it faster, but still worse than before.  Arg.