Hilo#
Inicializando la clase Thread#
Un hilo se crea utilizando el siguiente constructor:
Thread(callback, arg)
Este constructor utiliza dos parámetros:
Parámetro |
Descripción |
|---|---|
|
Una función previamente definida que se ejecutará como punto de entrada cuando se invoque el hilo. |
|
Opcional. Una tupla que se utiliza para pasar argumentos a la función de entrada del hilo. |
# Define the function "thread_print".
def thread_print():
brain.screen.print("Printing!")
# Construct a Thread "thread" with the
# Thread class.
thread = Thread(thread_print)
This thread object will be used in all subsequent examples throughout this API documentation when referring to Thread class methods.
Métodos de clase#
stop()#
The stop() method stops the thread.
Devoluciones: Ninguna.
sleep_for()#
The sleep_for(duration, units) method makes the thread sleep for a specified duration.
Parámetros |
Descripción |
|---|---|
|
La duración durante la cual el hilo debe dormir. |
|
Optional. A valid |
Devoluciones: Ninguna.