Skip to content

Instantly share code, notes, and snippets.

@arch-jslin
Created January 6, 2012 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arch-jslin/1571187 to your computer and use it in GitHub Desktop.
Save arch-jslin/1571187 to your computer and use it in GitHub Desktop.
coroutine
local counter = 0
local function proc1()
while counter < 100000000 do
counter = counter + 1
coroutine.yield()
end
end
local function proc2()
while counter < 100000000 do
counter = counter + 1
coroutine.yield()
end
end
local co1 = coroutine.create(proc1)
local co2 = coroutine.create(proc2)
while counter < 100000000 do
coroutine.resume(co1)
coroutine.resume(co2)
end
print(counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment