Naive thread affinity implementation; still not tested.