introduce for_each_thread() to replace the buggy while_each_thread() …