“pool de threads python” Respostas de código

Threading python

import threading
import time

def thread_function(name):
     print(f"Thread {name}: starting")
     time.sleep(2)
     print(f"Thread {name}: finishing")
 
my_thread = threading.Thread(target=thread_function, args=(1,))
my_thread.start()
time.sleep(1)
my_second_thread = threading.Thread(target=thread_function, args=(2,))
my_second_thread.start()
my_second_thread.join() # Wait until thread finishes to exit
Weary Wolverine

pool de threads python

from multiprocessing import Pool

def test( v ):
    print(v)
    return v

if __name__ == '__main__':
    with Pool(2) as p:
        print(p.map(test, range(5)))
Xerothermic Xenomorph

Respostas semelhantes a “pool de threads python”

Perguntas semelhantes a “pool de threads python”

Mais respostas relacionadas para “pool de threads python” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código