We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4793888 commit f080541Copy full SHA for f080541
Multithreading/stdy_threads.py
@@ -7,25 +7,27 @@
7
import _thread as thread
8
import time
9
10
+
11
# Example 1
12
def son(tid):
13
14
print("Executing son", tid)
15
16
17
def father():
18
19
k = 0
20
while True:
21
k = k + 1
22
thread.start_new_thread(son, (k,))
- if input() == "q":break
23
+ if input() == "q": break
24
25
26
# Example 2
27
def counter(myId, count):
28
for i in range(count):
29
time.sleep(1)
- print('[%s] => %s' % (myId,i))
30
+ print('[%s] => %s' % (myId, i))
31
32
if __name__ == "__main__":
33
@@ -34,7 +36,7 @@ def counter(myId, count):
34
36
35
37
38
for i in range(5):
- thread.start_new_thread(counter,(i,5))
39
+ thread.start_new_thread(counter, (i, 5))
40
41
time.sleep(5)
42
print("Exiting main thread")
0 commit comments