[PATCH] Reinstate const in next_thread()