waitall()
Suspend the current execution flow until all running tasks have been terminated.
Return value
This function returns no value.Example
local console = require "console"
local point_task
-- function to print points "." to the console forever
local function point()
while true do
-- sleep for one second
sleep(1000)
-- and print "."
console.write(".")
end
end
-- Launch a task using the point() function
point_task = async(point)
-- Launch a task that will terminate point_task in 10sec
async(function()
-- sleep for 10sec
sleep(10000)
-- then cancel point_task
point_task:cancel()
end)
-- Wait for all tasks to terminate before the program exits
waitall()