I'm trying to simplify the code of threads below:
import threading
def test1():
print("test1")
def test2():
print('test2')
thread1 = threading.Thread(target=test1)
thread2 = threading.Thread(target=test2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
So, I want to simplify this part of code below to:
# ...
thread1 = threading.Thread(target=test1)
thread2 = threading.Thread(target=test2)
thread1.start()
thread2.start()
thread1.join()
thread2.join()
Something like one line of code below:
# ...
threading.Threads(test1, test2).start().join()
Are there any ways to do this? and it's ok if it's not one line of code as long as it's simpler.