[Issue 3859] 100% CPU with thread in a loop

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 27 09:50:07 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3859



--- Comment #1 from bremby at seznam.cz 2010-02-27 09:50:03 PST ---
(In reply to comment #0)
> When I create a thread in a while loop, the first time it is created it works,
> the second time dual-core CPU gets up to 100% load and stucks in there. Tested
> with DMD 1.053. When compiled with latest GDC, only one core gets to 100%, the
> other one is fine.
> 

Sorry, guys, I am an idiot - of course the CPU gets up to 100%, the class
doNothing is written so. Anyway, the bug report is still valid: it never
finishes a 2nd loop.

> Code:
> 
> class doNothing : Thread;
> 
> while(condition){
>    Thread test = new doNothing();
>    test.start;
>    test.wait(1000);

++    writefln("1000 msec elapsed");

> }
> 
> Reproducible: Always.
> 
> System: Ubuntu 9.10, x86, Core 2 Duo
> 
> The doNothing thread just wastes CPU cycles, I wrote it as a test for the
> wait() method. The test instance gets terminated after the second that is
> waited in wait().

The code prints out the text only once. It correctly waits 1000ms, prints out
and then nothing happens ever again. Sorry for the messup.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list