Drastically improved chances of actually switching threads when yielding. This solution still has two weaknesses though: A presumably mostly theoretical one is that it might keep alternating between two threads while starving a third. The other more pertinent one is that it still doesn't handle threads waiting on condvars. Adaption of patch suggested by Artur Skawina. Thanks.