79 posts
Location
Germany
Posted 03 June 2013 - 11:14 AM
Hello,
I got a simple question:
Can lua handle Threads(Running multiple programs at once) ???
I've seen a nice program called frames and i like to know if there is a method to create Threads
892 posts
Location
Where you'd least expect it.
Posted 03 June 2013 - 11:18 AM
Use parallel.waitForAny or parallel.waitForAll. Example:
parallel.waitForAny(loadfile("onename"), loadfile("anothername"))
Parallel is great for basic usage.
7508 posts
Location
Australia
Posted 03 June 2013 - 11:18 AM
Threads no, coroutines yes. Basically a coroutine only one can run at any given time, and must yield (just like the computers) to allow other coroutines to run. They run so quickly they give the appearance of running at the same time, when they actually aren't.
Implementing a coroutine system is not the easiest of task, well debatably, depends on your understanding of code and how it works/runs, and your ability with Lua, however the CC devs have been nice to those who cannot implement their own and have supplied us with the
parallel api.