thread phobos and creating threads

Marcin dupek at gmail.com
Sat Sep 8 19:59:30 UTC 2018


//Ten przyklad po prostu tworzy wątek w którym są trzy obiekty
     import core.thread;
     import std.stdio: write, writeln, writef, writefln;

     class Sinus{
     double a;
         this(){writeln("No Args");}
         this(double a){writeln("U give 1 argument"); 
writeln(sin(a));}
         this(double[]a){writeln("U give an array"); 
foreach(double arg; a){writeln(sin(arg));}}
     double sin(double argument){return 
core.stdc.math.sin(argument);}
     }

void main()
{
     new Thread({
         auto jeden= new Sinus();
         auto dwa= new Sinus(11);
         auto trzy= new Sinus([1,2]);
         // Codes to run in the newly created thread.
     }).start();
}

Ok, Finally I've get it to work.


More information about the Digitalmars-d-learn mailing list