Sign in to follow this  
Followers 0
atrX

Scripting Basics: Threading

1 post in this topic

What is threading?

When calling a function regularly, your code will wait until the called function has finished or returned a value. If you want to run asynchronous functions you'll need to use threading which does not require your code to wait for the threaded function to finish or return a value.

 

When to use threading?

This all depends on the purpose of your script. In general, you want to avoid threading as much as possible as it requires extra resources to thread a function as opposed to regularly calling it. The only time you should ever thread a function is if you want to run this function asynchronously from your current code. A great example of this is calling functions on entities in an array. You'll usually want to thread these (there are exceptions, of course) as otherwise your're going to be waiting for one function to finish before going onto the next one.

 

How to use threading?

Threading is as simple as putting "thread" in front of your function call:

Please login or register to see this code.
1 person likes this

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0