start threads together python3

Asked

Viewed 30 times

0

How to start threads together ?

Context :
I have a class that extends the Threading.Thread. However, when I start threads, it seems to me that they are running sequentially.

Example :
1. Log in for;
2. The first thread is instantiated;
3. Executes the "run" method using the "start" method";
4. Expects execution to end - all of her;
5. Enter the next for iteration;
6. Back to step 1.

from threading import Thread
class Thread_test(Thread):
    def __init__(self):
        super().__init__()
    def run(self):
        ''' ALGUMA COISA PARA EXECUTAR'''


for i in range(10):
    thread = Thread_test()
    thread.start()
    thread.join()
  • That is exactly what is happening - and exactly what should happen. You know what the method join ago?

  • More or less ! I wanted threads to wait until the end of all other threads to continue the rest of the script...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.