Skip to content

Commit

Permalink
another example
Browse files Browse the repository at this point in the history
  • Loading branch information
nazaninsbr committed Aug 5, 2018
1 parent 54cd3bf commit ec45790
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Processes/two.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import multiprocessing

def worker(num):
print("Worker: ", num)

if __name__ == '__main__':
jobs = []

for i in range(5):
p = multiprocessing.Process(target=worker, args=(i, ))
jobs.append(p)
p.start()

for job in jobs:
job.join()
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@

here are the resources I used:
<ul>
<li>https://www.youtube.com/playlist?list=PLeo1K3hjS3uub3PRhdoCTY8BxMKSW7RjN</li>
<li>https://dev.to/nbosco/multithreading-vs-multiprocessing-in-python--63j</li>
<li>https://tutorialedge.net/python/python-multithreading-tutorial/</li>
<li>http://www.bogotobogo.com/python/Multithread/python_multithreading_creating_threads.php</li>
<li>https://pymotw.com/2/multiprocessing/basics.html</li>
</ul>
17 changes: 17 additions & 0 deletions Threads/two.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import threading

class Worker(threading.Thread):
def __init__(self):
super(Worker, self).__init__()

def run(self):
for i in range(10):
print(i)

if __name__ == '__main__':
thread1 = Worker()
thread2 = Worker()
thread3 = Worker()
thread1.start()
thread2.start()
thread3.start()

0 comments on commit ec45790

Please sign in to comment.