PDA

View Full Version : My thread is using 100% of the CPU!!!



cdarwin
13th June 2013, 00:37
Hello,

I've decided to separate my tcp listener's code from the GUI with QTthread. I've implemented this listener, standalone previously and it's not using any resources whatsoever. However, when I run the same code from a qt thread it's using 100% of a single core. I've tried using priorities but it didn't change anything. The listener is implemented with while(1). Same code compiled as a standalone console exe(no qt) uses 0% CPU. I've used both QtConcurrent and QThread, the result is the same. Any suggestions?

karankumar1609
13th June 2013, 07:07
LOOP will freeze all the activity of the parent code.
As you said that you use while(1) . but if you continuously listening then implement msSleep method of thread which will sleep your thread for some time . which cause a continuous execution of thread without interrupting other thread or process.

HAVE A LOOK AT QThread

CHEERS AND THE PROBLEM IS RESOLVED...

wysota
13th June 2013, 09:29
I've decided to separate my tcp listener's code from the GUI with QTthread.
Hmm... why?


The listener is implemented with while(1)
That's not a listener. That's a constant bugger to the CPU.