Reputation: 1001
def pingGetterLoop():
while(1):
pingGetter()
def mainLoop():
root.mainloop()
print("thread two")
threadTwo = Thread(target = mainLoop())
print("thread one")
threadOne = Thread(target = pingGetterLoop())
threadOne.start()
threadTwo.start()
for some reason threadTwo never starts and the output is always threadOne but when I switch the positioning of threadTwo over threadOne then threadOne doesn't run. I suppose it is the way they are getting into queue but, I don't know how to fix it.
Upvotes: 1
Views: 1473
Reputation: 3036
The problem is how you pass the functions to the threads. You call them instead of passing the callable. You can fix that by removing the brackets ()
:
print("thread two")
threadTwo = Thread(target=mainLoop)
print("thread one")
threadOne = Thread(target=pingGetterLoop)
As both functions contain a endless loop, you never get past calling the first one, which then loops forever.
Upvotes: 3