Task:wait( ) method

Suspend the execution flow until the Task have been terminated, allowing other tasks to run during this time.

Return value

This method returns the Task return values.

Example

-- example that will draw french flags concurrently local console = require "console" -- function to print a colored square to the console forever local function draw(color) while true do -- sleep for one second sleep(1000) -- and print a colored square console.writecolor(color, "■") if color == "red" then console.write("\n") end end end -- Launch 3 task using the point() function async(draw, "blue") async(draw, "white") async(draw, "red") -- Wait for all tasks to terminate before the program exits waitall()