Difference between revisions of "X Threads"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
 
Line 9: Line 9:
 
=== Example ===
 
=== Example ===
 
'''Simple example of getting result from a thread'''
 
'''Simple example of getting result from a thread'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "Threads"
 
require "Threads"
 
local thread = Thread.new()
 
local thread = Thread.new()

Latest revision as of 15:32, 13 July 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform pc.pngPlatform mac.pngPlatform winrt.pngPlatform win32.png
Available since: 2018.10

Description

The Threads plugin provides the ability to run Lua code in separate threads, taking advantage of multiple cores where available.

Example

Simple example of getting result from a thread <syntaxhighlight lang="lua"> require "Threads" local thread = Thread.new() thread:setFunction(function() local a = 0 for i = 1, 10000000 do a += 1 end return i end) thread:execute() local ok = false while not ok do ok = thread:getResult() end print("woot!") </source>

Class

Thread