-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththread.py
More file actions
49 lines (38 loc) · 1.15 KB
/
thread.py
File metadata and controls
49 lines (38 loc) · 1.15 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
from threading import Thread
import threading
# def even_odd ():
# evenNum()
# oddNum()
# print(threading.current_thread().getName())
# def evenNum ():
# print("Even numbers are :")
# for x in range(20):
# if x%2 == 0:
# print(x)
# def oddNum ():
# print("Odd numbers are :")
# for x in range(20):
# if x%2 != 0:
# print(x)
# t = Thread(target=even_odd,name="even_Odd Thread")
# t.start()
# #########################################################################################################
# class myT (Thread):
# def run(self):
# print(threading.current_thread().getName())
# for x in range(1,10):
# for j in range(1,x+1):
# print("*",end=" ")
# print("\r")
# cla = myT()
# cla.start()
##########################################################################################################
def n():
print (threading.current_thread().getName(),"has started")
for x in range(1,10):
print(x)
print (threading.current_thread().getName(),"has ended")
t1 = Thread(target=n)
t2 = Thread(target=n)
t1.start()
t2.start()