Skip to content

Commit bef8f65

Browse files
One functionality executed by multiple threads.
1 parent ed51cab commit bef8f65

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Multithreading5.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from threading import *
2+
class MyThread:
3+
def display(self):
4+
for i in range(10):
5+
print("Child Thread executed by:",current_thread().name,"for",i,"time")
6+
obj=MyThread()
7+
t1=Thread(target=obj.display)
8+
t2=Thread(target=obj.display)
9+
t3=Thread(target=obj.display)
10+
t4=Thread(target=obj.display)
11+
t1.start()
12+
t2.start()
13+
t3.start()
14+
t4.start()
15+
for i in range(10):
16+
print("Main Thread executed by:",current_thread().name,"for",i,"time")
17+

0 commit comments

Comments
 (0)