All pastes #141241 Raw Edit

line

public cpp v1 · immutable
#141241 ·published 2006-08-20 22:03 UTC
rendered paste body
import std.thread; /// Import thread functions from the standard libraryimport std.stdio; /// Also import standard in/output functionsclass UselessThread : Thread { /// Create a new class (custom variable type), derived from the Thread class from std.thread	Thread p; /// This is a member variable of the new data type UselessThread, ask line or google for more info	this(Thread parent) { /// constructor		p=parent;	}	int run() {		p.wait(); /// Wait until the parent thread exits		return 0; /// then return and exit too.	}}int main() { /// Our main function	UselessThread yawn; /// Create a new variable of type UselessThread	yawn = new UselessThread (Thread.getThis()); /// and assign to it a new object of the type UselessThread	yawn.start(); /// Start the "yawn" thread.	writefln("Counting seconds!");	for (int i=1; i<=10; ++i) {		yawn.wait(1000);		writefln(i, " seconds passed!");	}	return 0;}