This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
gknova61's profile picture

2 parallel functions running, only one of them recieving events

Started by gknova61, 12 February 2014 - 04:46 AM
gknova61 #1
Posted 12 February 2014 - 05:46 AM
Basically I've got this code:

function thread1()
while true do
local ev = {os.pullEvent()}
print("THREAD 1: "..ev[1])
end
end

function thread2()
while true do
local ev = {os.pullEvent()}
print("THREAD 2: "..ev[1])
end
end

parallel.waitForAll(thread1(),thread2(),thread3())

Only the first function called (thread1) gets a pull event whenever I press a key like this:


What I want to be able to do is make it so both functions recieve the pull event so they can process it their own separate ways instead of just 1 function getting the pull events.
Edited on 12 February 2014 - 04:46 AM
theoriginalbit #2
Posted 12 February 2014 - 05:52 AM
Have a read of this thread, your answer is located in the first response, however make sure that you read my response for a more in-depth explanation as to why it happens.
gknova61 #3
Posted 12 February 2014 - 08:08 PM
Thank you so much! Resolved!