Jump to content




2 parallel functions running, only one of them recieving events


2 replies to this topic

#1 gknova61

  • Members
  • 74 posts

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:
Posted Image

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 by gknova61, 12 February 2014 - 05:46 AM.


#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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.

#3 gknova61

  • Members
  • 74 posts

Posted 12 February 2014 - 08:08 PM

Thank you so much! Resolved!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users