|
@@ -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()
|
|
|
|