Last active
May 7, 2020 21:38
-
-
Save EwertonBello/6cc93a3db95025660ad1c38387436f4d to your computer and use it in GitHub Desktop.
exemplo simples de multiprocessing com Process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from multiprocessing import Process | |
def tarefa(seg): | |
time.sleep(seg) | |
print(f'Concluído em {seg} segundos...') | |
def main(): | |
p1 = Process(target=tarefa, args=(4,)) | |
p1.start() | |
p2 = Process(target=tarefa, args=(2,)) | |
p2.start() | |
p3 = Process(target=tarefa, args=(3,)) | |
p3.start() | |
p1.join() | |
p2.join() | |
p3.join() | |
print('Concluído!') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment