-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (23 loc) · 738 Bytes
/
main.py
File metadata and controls
29 lines (23 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import threading
cond = threading.Condition()
liste = []
def waiter(cond, liste):
cond.acquire()
while len(liste) == 0:
cond.wait()
print("le mot de passe est:", liste.pop())
cond.release()
t1 = threading.Thread(target=waiter, args=(cond, liste))
t2 = threading.Thread(target=waiter, args=(cond, liste))
t3 = threading.Thread(target=waiter, args=(cond, liste))
t4 = threading.Thread(target=waiter, args=(cond, liste))
t5 = threading.Thread(target=waiter, args=(cond, liste))
threads = [t1, t2, t3, t4, t5]
for t in threads:
t.start()
for i in range(0, 5):
cond.acquire()
mdp = input("Entrez un mot de passe:")
liste.append(mdp)
cond.notify()
cond.release()