What is the best practice of organization multi-threading ?
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 16 10:45:54 PDT 2015
On 03/15/2015 01:53 PM, Suliman wrote:
> I have App that read config sections. If the section is true I want to
> run it in new thread.
>
> if (parseconfig.obsmpplots_load == "true")
> {
> auto obsmpplots = new ObsmpPlots(db);
> auto theTask = task(&obsmpplots.getPlots);
> theTask.executeInNewThread();
>
> }
>
> if(parseconfig.nadisa_load == "true")
> {
> auto nadisa = new Nadisa(db);
> auto theTask = task(&nadisa.getPlots);
> theTask.executeInNewThread();
> }
>
> It's seems work, but I do not sure that I doing it's right.
I don't see any problem. The threads start, do their jobs, and terminate.
If the threads need to produce results that they need to pass to their
owner (as messages), then std.concurrency is another option.
Ali
More information about the Digitalmars-d-learn
mailing list