Python multithread functions

I've got a python function and want to run it in multithreading mode. How can I do it?

pythonmultithreading
2 votesJW234.00
1 Answers
NN138.00
1

There are couple of ways you can do that. One of them is the following

import threading

threads = []
tr = threading.Thread(target=my_func, args=(arg1, arg2, etc))
threads.append(tr)
tr.start()

for tr in threads:
    tr.join()

Just define my_func function and put the correct list of arguments.

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?