Python: How To Multi-thread A Function That Returns Multiple Values
I have a program that has two functions that returns 2 values for each function. Everything runs fine without any parallelization. However what I am hoping to achieve is to run eac
Solution 1:
You might want to modify your function a little bit to use Queue
for getting results.
import threading, Queue
def func1(queue):
x = 2
y = 5
queue.put((x, y))
queue = Queue.Queue()
new_thread = threading.Thread(target=func1, args=(queue, ))
new_thread.start()
new_thread.join()
x, y = queue.get()
Post a Comment for "Python: How To Multi-thread A Function That Returns Multiple Values"