I am trying to figure out how to do multithreading in Python, namely how to use the map function to call my function with multiple variables.
My code:
from multiprocessing.dummy import Pool as ThreadPool
def myFunc(a, b):
print(a * b)
arr = [4, 8, 10, 7, 9]
arr2 = [2, 1, 3, 4, 2]
pool = ThreadPool(4)
results = pool.map(myFunc, arr, arr2)
pool.close()
pool.join()
It get the following error from the pool.map function call:
TypeError: '<=' not supported between instances of 'list' and 'int'
Which I don't quite get. From the documentation I should be able to do this.
What am I missing?