Change heartbeat thread to use reschedule instead of sleep.