线#
初始化线程类#
使用以下构造函数创建线程:
Thread(callback, arg)
此构造函数使用两个参数:
范围 |
描述 |
---|---|
|
先前定义的函数,将在线程调用时作为入口点执行。 |
|
**可选。**用于向线程入口函数传递参数的元组。 |
# 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.
类方法#
stop()#
The stop()
method stops the thread.
**返回:**无。
sleep_for()#
The sleep_for(duration, units)
method makes the thread sleep for a specified duration.
参数 |
描述 |
---|---|
期间 |
线程应休眠的持续时间。 |
单位 |
Optional. A valid TimeUnits type. The default is |
**返回:**无。