Hi guys!
I don't get why value of 'a' isn't changed in the end?
require "Threads"
local thread = Thread.new()
local a=1
thread:setFunction(function()
for i=1, 1000000 do
a=a+1
end
end)
thread:execute()
local timerDelayed = Timer.delayedCall(2000, function()
print("a=",a) --prints a=1, though I expected a=1000000
end) |
Thx!
p.s. and how to properly pass args?
require "Threads"
local thread = Thread.new()
local a=1
thread:setFunction(function(arg)
print(arg) --nothing prints, whole function isn't executed
for i=1, 1000000 do
a=a+1
end
end)
thread:execute("test arg") |
Comments
https://deluxepixel.com
Likes: SinisterSoft
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: SinisterSoft, Apollo14, talis, pie
Likes: PaulR
Fragmenter - animated loop machine and IKONOMIKON - the memory game