xxxxxxxxxx
import core.sys.posix.pthread;
import core.memory;
import core.thread;
import std.stdio;
extern(C) void* foo(void*)
{
thread_attachThis();
scope(exit)
thread_detachThis();
foreach(_; 0..1000) {
new int;
new int[1000];
}
writeln(`foo done`);
return null;
}
void main()
{
pthread_t thread;
foreach(_; 0..1000) {
auto status = pthread_create(&thread, null, &foo, null);
assert(status == 0);
foreach(i; 0..1000)
GC.collect();
pthread_join(thread, null);
}
writeln(`main done`);
}