-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetermining_the_current_thread.py
More file actions
61 lines (47 loc) · 1.27 KB
/
Copy pathdetermining_the_current_thread.py
File metadata and controls
61 lines (47 loc) · 1.27 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import threading
import time
def first_function():
print(f"{threading.current_thread().getName()} is starting \n")
time.sleep(2)
print(f"{threading.current_thread().getName()} is ended \n")
return
def second_function():
print(f"{threading.current_thread().getName()} is starting \n")
time.sleep(2)
print(f"{threading.current_thread().getName()} is ended \n")
return
def third_function():
print(f"{threading.current_thread().getName()} is starting \n")
time.sleep(2)
print(f"{threading.current_thread().getName()} is ended \n")
return
def forth_function():
print(f"{threading.current_thread().getName()} is starting \n")
time.sleep(2)
print(f"{threading.current_thread().getName()} is ended \n")
return
if __name__ == "__main__":
t1 = threading.Thread(
name='first_function',
target=first_function,
)
t2 = threading.Thread(
name='second_function',
target=second_function,
)
t3 = threading.Thread(
name='third_function',
target=third_function,
)
t4 = threading.Thread(
name='forth_function',
target=forth_function,
)
t1.start()
t2.start()
t3.start()
t4.start()
t1.join()
t2.join()
t3.join()
t4.join()