Bladeren bron

Clarify the userdata in the threads tutorial.

Juan Linietsky 6 jaren geleden
bovenliggende
commit
387890d0ba
1 gewijzigde bestanden met toevoegingen van 9 en 4 verwijderingen
  1. 9 4
      tutorials/threads/using_multiple_threads.rst

+ 9 - 4
tutorials/threads/using_multiple_threads.rst

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