schedule: set thread to NULL when there is no next thread