There are many examples online for thread pools but almost all deal with the concept of passing functions around and calling those (like here or here). But I have some objects which inherit from threading.Thread
and I want only some of them to be running at any time. Here is a minimal working example
class Human (threading.Thread):
def run (self):
print ("taking a nap")
sleep (60*60*8)
human_population = 7000000000
for i in range(human_population):
human=Human()
human.start()
Ignoring for the mmoment that 7B objects would crush my computer, I am looking for a very easy way to run only a manageable number of threads at any time, for example, N= 10
threads in a FIFO fashion.