KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a thread which extends Thread. The code looks a little like this; class MyThread(Thread): def run(self): # Do stuff my_threads = [] while has_jobs() and len(my_threads) < 5: new_thread = MyThread(next_job_details()) new_thread.run() my_threads.append(new_thread) for my_thread in my_threads my_thread.join() # Do stuff So here in my pseudo code I check to see if there is any jobs (like a db etc) and if there is some jobs, and if there is less than 5 threads running, create new threads. So from here, I then check over my threads and this is where I get stuck, I can use .join() but my understanding is that - this then waits until it's finished so if the first thread it checks is still in progress, it then waits till it's done - even if the other threads are finished.... so is there a way to check if a thread is done, then remove it if so? eg for my_thread in my_threads: if my_thread.done(): # process results del (my_threads[my_thread]) ?? will that work...
Tags (comma-separated)
Save Edits
Cancel