0

I want to wait for a thread before moving to next one. I was using .join() method but that freezes me gui. I want my gui to be responsive meanwhile. Here is my code so far.

  class mainqueue:
      def __init__(self):
          self.mainQueue=queue.Queue()

      def addItem(self,q):
          self.mainQueue.put(q)

      def startConverting(self,funcName):
          for i in range(2):
              print("starting thread {}".format(i))
              t = Thread(target = self.threaded_function)
              t.start()
              t.join()

      def threaded_function(self):

          time.sleep(5)
          print(self.mainQueue.get())


  m=mainqueue()
  def helloCallBack():
     m.addItem("a")
     m.addItem("b")
     m.addItem("c")
     m.startConverting("test")

  B = tkinter.Button(top, text ="Hello", command = helloCallBack)

  B.pack()
  top.mainloop()
Abdul Ahad
  • 99
  • 2
  • 9
  • Your answer can be found here: https://stackoverflow.com/questions/11968689/python-multithreading-wait-till-all-threads-finished – Xion Dec 10 '18 at 17:58
  • "I want to wait for a thread before moving to next one" - then why are these two different threads? – user2357112 Dec 10 '18 at 18:48
  • if I am getting your question then, I want to dequeue one after another, obviously after previous ones completition. These two, may be more depending on the numbers of item i want to dequeue. – Abdul Ahad Dec 10 '18 at 18:57
  • @Xion that .joins() method itself is hanging my gui. – Abdul Ahad Dec 10 '18 at 19:45

0 Answers0