Thread creation and sleep function in python
Program discussed
from threading import Thread
import threading
import time,random
class mythread(Thread):
def __init__(self,n):
Thread.__init__(self,name=n)
def run(self):
print("The child thread name is :",self.getName())
r=random.randint(1,5)
time.sleep(r)
print(self.getName()," sleep for :",r)
if __name__=="__main__":
print("the parent thread is :",threading.current_thread().getName())
li=[]
no=int(input("Enter the no of thread to create"))
for i in range(no):
li.append(mythread("rosh "+str(i+1)))
for j in li:
j.start()
In questa pagina del sito puoi guardare il video online Thread creation and sleep function in python part 1 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Roshni Thanka 04 aprile 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 229 volte e gli è piaciuto 5 spettatori. Buona visione!