title: Why can't i use global variable in a QThread based class?
body: <p>Suppose the minimal case , which contains one class named <code>Worker</code> based on <code>QThread</code> , and another named <code>Parser</code> , which is a global class , resided in <code>Worker</code> class.</p>
  
  <pre><code># parser.h
  class Parser;
  extern Parser *App_Parser;
  
  class Parser {
      bool init() { App_Parser = new Parser(); }
  }
  
  # parser.cpp
  Parser *App_Parser = 0;
  
  # worker.cpp
  class Worker: public QThread {
      Worker(int thread_id , QObject *parent) {
          Parser::init ();
          connect ( App_Parser , .... , this , SLOT(parseCompleted()) );
      }
      private slots:
             void parseCompleted () { 
                  qDebug() &lt;&lt; "Thread ID: " &lt;&lt; thread_id &lt;&lt; " completed"; 
             }
  }
  </code></pre>
  
  <p>So here goes the problem , if i created <code>12</code> Worker in a higher class , i sometimes could see invalid <code>thread_id</code> , and it's always just one above it , in this case , always <code>13</code>.</p>
  
  <p>And if i don't use App_Parser , but just use <code>new Parser()</code> for an  simple instance , it works.</p>
  
  <p>So i'm thinking about why global variables shouldn't be used here.</p>