title: How to limit QThread number
body: <p>Is it possible to limit number of threads started with <code>QtCore.QThread</code> via <code>Queue</code>. The code below starts as many running threads as there were submitted.</p>
  
  <pre><code>from PyQt4 import QtCore, QtGui
  import Queue as queue
  
  app = QtGui.QApplication([])
  theQueue = queue.Queue()
  
  class TheThread(QtCore.QThread):
      def __init__(self, theQueue, parent=None):
          QtCore.QThread.__init__(self, parent)
          self.theQueue = theQueue
  
      def run(self):
          while True:
              task = self.theQueue.get()
              self.sleep(1) 
              self.theQueue.task_done()
  
  threads=[]
  for i in range(1, 3): 
      thread = TheThread(theQueue)
      threads.append(thread)
      thread.start()
  
  for i in range(len(threads)):
      theQueue.put(i)
  </code></pre>