Answers for "python wait until all threads finish"

0

python wait for thread to finish

t1 = Thread(target=call_script, args=(scriptA + argumentsA))
t2 = Thread(target=call_script, args=(scriptA + argumentsB))
t3 = Thread(target=call_script, args=(scriptA + argumentsC))

t1.start()
t2.start()
t3.start()

# join() stalls program execution until the thread stops executing
t1.join()
t2.join()
t3.join()
Posted by: Guest on June-02-2021
0

python wait until all threads finish

import threading
import time

def loop1_10(timeSleep):
    for i in range(1, 11):
        time.sleep(timeSleep)
        print("timeSleep:"+str(timeSleep)+": ",i)

t1 = threading.Thread(target=loop1_10, args=[1])
t2 = threading.Thread(target=loop1_10, args=[2])
t3 = threading.Thread(target=loop1_10, args=[0.5])

t1.start()
t2.start()
t3.start()

t1.join()
t2.join()
t3.join()

print("All thread is done !!!")
Posted by: Guest on July-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language