set_thread_num function

Set the number of threads