“hilo de pitón con parámetros” Código de respuesta

hilo de pitón con parámetros

thread = threading.Thread(target=function, args=(arg1, arg2), kwargs=dict(x=3,delay=0.25))
Arno Deceuninck

hilo con args python

dRecieved = connFile.readline()
processThread = threading.Thread(target=processLine, args=(dRecieved,))  # <- note extra ','
processThread.start()
SharxNZ

Pase la variable al objetivo de subproceso

from threading import Thread
from time import sleep
def run(name):
    for x in range(10):
        print("helo "+name)
        sleep(1)
def run1():
    for x in range(10):
        print("hi")
        sleep(1)
T=Thread(target=run,args=("Ayla",))
T1=Thread(target=run1)
T.start()
sleep(0.2)
T1.start()
T.join()
T1.join()
print("Bye")
Repulsive Rattlesnake

Respuestas similares a “hilo de pitón con parámetros”

Preguntas similares a “hilo de pitón con parámetros”

Más respuestas relacionadas con “hilo de pitón con parámetros” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código