add some multiprocess and race condition examples

This commit is contained in:
Mia von Steinkirch 2020-03-04 10:12:53 -08:00
parent 5224dc91ca
commit be98abd3b5
4 changed files with 57 additions and 4 deletions

View file

@ -8,7 +8,7 @@ import threading
def worker(n):
sleep = random.randrange(1, 10)
time.sleep(sleep)
print("Worker {}: sleeping for {} seconds.".format(n, sleep))
print("Worker {} from {}: sleeping for {} seconds.".format(n, threading.get_ident(), sleep))
for i in range(5):