More efficient ThreadScheduler implementation.