title: QThread threadpool
body: <p>I am trying to write thread poll with QThread.</p>
  
  <pre><code>class ThreadPool: public QObject
  {
      Q_OBJECT
  
  public:
      ThreadPool(int maxThreads);
      void addTask(MyTask *task);
  private:
      int maxThreads;
      QMutex mutex;
      QVector&lt;QPair&lt;bool, QThread&gt;&gt; threads;
      QThread *getFreeThread();
  public slots:
     void freeThread();
  };
  
  
  void ThreadPool::addTask(MyTask* task)
  {
      QThread *thread = getFreeThread();
      task-&gt;moveToThread(thread);
      connect(thread, SIGNAL(started()), task, SLOT(doWork()));
      connect(task, SIGNAL(workFinished()), thread, SLOT(quit()));
      connect(thread, SIGNAL(finished()), task, SLOT(deleteLater()));
      connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
      connect(thread, SIGNAL(finished()), this, SLOT(freeThread()));
      thread-&gt;start();
  }
  </code></pre>
  
  <p>I am creating a limited number of threads in which I want to perform tasks.
  However, I do not understand how to get the number of the freed thread.
  I know about QThreadPool and Qtconcurrent, but I dont want to use it.
  Perhaps, it is worth noting at each thread in QPair's vector is it free or not.</p>