Reduce loops in init_threads() and exit_threads()