Threading bugs

Tristam MacDonald swiftcoder at gmail.com
Tue Jun 26 13:36:40 PDT 2007


So, I am sure that I must be missing something simple, that is causing my multi-threading code in D fail miserably. I have cut it down to the smallest code sample that exhibits the problem, and I would be grateful if someone could have a look and let me know why...

import std.thread;
import std.stdio;

class Main
{
	this() {
		writefln("starting");

		Thread worker = new Thread(&workerMain);
		worker.start();
	}
	~this() {
		writefln("ending");
	}
	
	int workerMain()
	{
// -- disabled in case of deadlock in std.format, but never reached anyway
//		writefln("In Thread");
		return 0;
	}
	
	Thread worker;
}

int main()
{
	Main m = new Main();
		
	return 0;
}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.d
Type: 
Size: 399 bytes
Desc: not available
Url : http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20070626/b27cb0de/attachment.txt 


More information about the Digitalmars-d-learn mailing list