has_thread()#

Determine if a thread of a given name exists and is currently running.

Examples#

 1import time
 2
 3
 4def slow_thread():
 5    py5.println('starting slow thread')
 6    time.sleep(7)
 7    py5.println('finishing slow thread')
 8
 9
10def setup():
11    py5.launch_thread(slow_thread, name='slow thread')
12
13
14def draw():
15    if py5.has_thread('slow thread'):
16        py5.background(0, 255, 0)
17    else:
18        py5.background(255, 0, 0)

Description#

Determine if a thread of a given name exists and is currently running. You can get the list of all currently running threads with list_threads().

Syntax#

has_thread(name: str) -> None

Parameters#

  • name: str - name of thread

Updated on September 11, 2021 16:51:34pm UTC