I posted a bug report for this a few days ago (2890). I got as far as finding out that it is a file locking problem caused by what looks like a compiler bug re calling the destructor of a struct. The following patch to std.stdio works around the problem, but is hardly a fix.
$ diff dmd/src/phobos/std/stdio.d stdio.d 922c922 < //return LockingTextWriter(this); --- > return LockingTextWriter(this); 925,926c925,926 < auto result = LockingTextWriter(this); < return result; --- > //auto result = LockingTextWriter(this); > //return result; On Mon, 27 Apr 2009 22:53:04 +0000, dsimcha wrote: > The following small test program seems to have a weird deadlock or > something: > It should keep printing the phrase "Doing stuff." forever, but it only > gets > through maybe two iterations before its CPU usage does to zero and it > stops printing, at least on my computer. Has anyone noticed any bad > behavior with std.stdio and multithreading? > > import core.thread, std.stdio; > > void main() { > Thread[] myThreads; > foreach(i; 0..4) { > myThreads ~= new Thread( { doStuff(); }); myThreads[$ - > 1].start; > } > } > > > > void doStuff() { > while(true) { > synchronized { > writeln("Doing stuff."); > } > } > } > > > If the writeln line is commented out, this thing keeps executing the > empty loop with measurable CPU usage.