Here I am creating 3 threads for one server and 2 clients. I wanted to stop the thread and make the port numbers reusable after one execution. My code is
t1=threading.Thread(target=serv)
t2=threading.Thread(target=cli1)
t3=threading.Thread(target=cli2)
t1.start()
time.sleep(2)
t2.start()
time.sleep(2)
t1.start()
time.sleep(2)
Here serv
, cli1
and cli2
are the functions that contains client server programs.
How do I terminate these threads ?
您需要修改serv cli1和cli2函数,以便在设置了将在主线程中设置的标志时终止它们。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.