title: A Simple pthread_create causing 100% CPU usage in Qt
body: <p>When a simple Thread is run with just an infinite loop in it causing 100% CPU, how come is this possible?</p>
  
  <p>My thread call is as follows on a QEvent in Qt dialog class, Say on a button click.</p>
  
  <pre><code>  pthread_t thread_id;
    pthread_create( &amp;thread_id, NULL, DataCollectionThread, (void*) this );
  </code></pre>
  
  <p>And my thread procedure is,</p>
  
  <pre><code>void* DataCollectionThread( void* pParam )
  {
     ((m_DataCollection*)pParam)-&gt;m_ReadDatafromport();
     return NULL;
  }
  </code></pre>
  
  <p>And this <code>ReadData()</code> contains...</p>
  
  <pre><code>while(1)
  {
  }
  </code></pre>
  
  <p>My requirement is collecting data from serial port and plot a graph continuously. But as the CPU usage is 100%, any hardware interrupt in between plotting cause the plotting to stall, as the <code>CPU</code> switches the task to handle interrupt.</p>
  
  <p>I am calling this thread in a <code>Qt::Dialog</code> based class. I am pretty sure that nothing other than this is triggered. What's wrong with this? Does a simple infinite loop causes 100% CPU consumption eh? Or Is there any problem with using pthread_create in Qt?</p>
  
  <p><strong>EDIT</strong>:For Jonathon Reinhart</p>
  
  <p>This is the actual while loop</p>
  
  <pre><code>while( 1 )
      {
  
              while(( Dataisavailable))
              {
                   //push the read data to stack
              }
  
  
  
          if(!m_DataReadable)
              break;
        }
  </code></pre>