Simple Multithreading in Python || Python

 

In this we are going to see a program on Simple Multithreading in Python Programming Language.


import threading as th
import time

class T:
    def displayThread(self,n):
        print(n)


t=T()

for i in range(1,20):
    time.sleep(1)
    t1 = th.Thread(target=t.displayThread,args=("Thread 1",))
    t2 = th.Thread(target=t.displayThread,args=("Thread 2",))
    t1.start()
    time.sleep(1)
    t2.start()

# Coded by Saahil

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post