Clarify the userdata in the threads tutorial.

This commit is contained in:
Juan Linietsky
2019-04-24 09:56:28 -03:00
parent b9114482f2
commit 387890d0ba

View File

@@ -25,13 +25,18 @@ Creating a thread is very simple, just use the following code:
# The thread will start here.
func _ready():
thread = Thread.new()
thread.start(self, "_thread_function", "Wafflecopter")
# third argument is optional userdata, it can be any variable
thread.start(self,"_thread_function","Wafflecopter")
# Run here and exit.
# Run here and exit
# The argument is the userdata passed from start()
# If no argument was passed, this one still needs to
# Be here and it will be null.
func _thread_function(userdata):
print("I'm a thread! Userdata is: ", userdata)
# Print the userdata ("Wafflecopter")
print("I'm a thread! Userdata is: ",userdata)
# Thread must be disposed (or "joined"), for portability.
# Thread must be disposed (or "Joined"), for portability
func _exit_tree():
thread.wait_to_finish()