Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Thread

Inherits: RefCounted < Object

A unit of execution in a process.

Description

A unit of execution in a process. Can run methods on Objects simultaneously. The use of synchronization via Mutex or Semaphore is advised if working with shared objects.

Warning:

To ensure proper cleanup without crashes or deadlocks, when a Thread's reference count reaches zero and it is therefore destroyed, the following conditions must be met:

Tutorials

Methods

String

get_id ( ) const

bool

is_alive ( ) const

bool

is_started ( ) const

void

set_thread_safety_checks_enabled ( bool enabled ) static

Error

start ( Callable callable, Priority priority=1 )

Variant

wait_to_finish ( )


Enumerations

enum Priority:

Priority PRIORITY_LOW = 0

A thread running with lower priority than normally.

Priority PRIORITY_NORMAL = 1

A thread with a standard priority.

Priority PRIORITY_HIGH = 2

A thread running with higher priority than normally.


Method Descriptions