S
S
Sasha2019-01-25 09:13:11
Python
Sasha, 2019-01-25 09:13:11

How to take data from an array in multiple threads?

Hello. Need help with multithreading. I have a list with objects, each object will have its own tasks that need to be done. There will be a function that will run in several threads, and an object from the list will be passed to it. And this function will determine what to do with it next. Tell me how to take objects from an array in several threads?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2019-01-25
@Fanat1kk

from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor(max_workers=NUM_WORKERS) as executor:
    results = executor.map(fn, list_of_objects)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question