--------main.lua
-- Wait data with ":getCount()>0"
love.thread.newThread[[
local channel=love.thread.getChannel("CHN_1")
print("TH 1: Looping...")
repeat until channel:getCount()>0
print("TH 1: Received",channel:pop())
]]:start()
-- Wait data with ":demand()"
love.thread.newThread[[
local channel=love.thread.getChannel("CHN_2")
print("TH 2: Demanding...")
local v=channel:demand()
print("TH 2: Received",v)
]]:start()
-- Control group, :demand() will timeout after 5s
love.thread.newThread[[
local channel=love.thread.getChannel("CHN_3")
print("TH 3: Demanding...")
local v=channel:demand(2.6)
print("TH 3: Received",v)
]]:start()
love.timer.sleep(1)
love.thread.getChannel("CHN_1"):push("DATA 1")
love.thread.getChannel("CHN_2"):push("DATA 2")
function love.draw() love.graphics.print("Check console",0,0,0,6) end