Thread creation and sleep function in python part 1

Publicado em: 04 Abril 2020
no canal de: Roshni Thanka
229
5

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()


Nesta página do site você pode assistir ao vídeo on-line Thread creation and sleep function in python part 1 duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Roshni Thanka 04 Abril 2020, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 229 vezes e gostou 5 espectadores. Boa visualização!