-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path42-Mutithread.py
More file actions
42 lines (30 loc) · 758 Bytes
/
42-Mutithread.py
File metadata and controls
42 lines (30 loc) · 758 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
30
31
32
33
34
35
36
37
38
39
40
41
42
'''
author : Jaydatt Patel
MultiThread in Python
class threading.Thread(
group: None = None,
target: ((...) -> object) | None = None,
name: str | None = None,
args: Iterable[Any] = (),
kwargs: Mapping[str, Any] | None = None,
*,
daemon: bool | None = None
)
'''
import threading
def fun1(str):
for i in range(5):
print(str)
def fun2(str, num):
for i in range(5):
print(str)
if __name__ =="__main__":
t1 = threading.Thread(target=fun1, args=("+"),name = "function-1")
t2 = threading.Thread(target=fun2, args=('-',123), name = "function-2")
print("t1.name : ",t1.name)
print("t2.name : ",t2.name)
t1.start()
t2.start()
t1.join()
t2.join()
print("Done!")