2021年1月17日星期日

Multithreading Keep threads active

I am struggling with multi threading my code. I want to ALWAYS have 10 active threads, but I am not sure how. Current code:

import threading  from random import randint  import os  import names  import random  import time    threads = 10    def f():      print("my actual function is 200+ lines")      return    for i in range(threads):      t = threading.Thread(target=f)      t.start()  

My current code starts 10 threads, but does not maintain them, keep active. Thank you for the help

edit: have also tried with while True, but no luck.

https://stackoverflow.com/questions/65769087/multithreading-keep-threads-active January 18, 2021 at 01:05PM

没有评论:

发表评论