thread and gc.fullCollect
Ant
duitoolkit at yahoo.ca
Thu Jan 11 17:19:37 PST 2007
I don't get this.
If I run this program count is printed about 50 times
and takes 5 seconds to complete as expected.
but if uncomment line 19 count is printed only twice and the program
exist almost immediately...
Why is that?
Ant
private import std.gc;
private import std.thread;
private import std.c.time;
private import std.stdio;
class Foo
{
int count;
this()
{
Thread ft = new Thread(&foo);
ft.start();
std.gc.fullCollect(); // ok
while ( ft.getState() != Thread.TS.TERMINATED )
{
// line 19 std.gc.fullCollect();
writefln("Count = %s ", count++);
std.c.time.usleep(100000);
}
}
int foo()
{
std.c.time.sleep(5);
return true;
}
}
void main()
{
new Foo();
}
More information about the Digitalmars-d-learn
mailing list