Thread creation and sleep function in python part 1

Publicado el: 04 abril 2020
en el 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()


En esta página del sitio puede ver el video en línea Thread creation and sleep function in python part 1 de Duración hora minuto segunda en buena calidad , que subió el usuario Roshni Thanka 04 abril 2020, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 229 veces y le gustó 5 a los espectadores. Disfruta viendo!