Threads Done!

DF deefriend at ymail.com
Wed Nov 19 10:42:05 PST 2008


DF Wrote:

> DF Wrote:
> 
> > /**
> >  * Testing.
> >  */
> > module Test;
> > 
> > import std.thread;
> > import std.stdio;
> > 
> > class DerivedThread : Thread {
> > 
> >      this() {
> >          super(&run);
> >      }
> > 
> > private :
> >      int run() {
> >         writefln("Derived thread running.\n" );
> > 	return 0;
> >      }
> > }
> > 
> > void main() {
> > 	Thread derived = new DerivedThread();
> > 	derived.start();
> > }
> > 
> > This code makes no output. Why?
> 
> The code above should be changed to:
> /**
> * Testing.
> */
> module Test;
> 
> import std.thread;
> import std.stdio;
> 
> class DerivedThread : Thread {
> 
>      this() {
>          super(&run);
>      }
> 
> 
>      int run() {
>         writefln("Derived thread running.\n" );
>         return 0;
>      }
> }
> 
> void main() {
>         Thread derived = new DerivedThread();
>         derived.start();
>         derived.wait();
> }
> 
> Now it works thanks.

P.S. I'm using Digital Mars D Compiler v2.014



More information about the Digitalmars-d mailing list