Hi,

when I execute this code I have 7 7 7 as result, I think I understand why.

How can I execute a special task for one element ?

import std.stdio;
import std.parallelism;

void main(string[] args)
{
        class Account
        {
                public this(int id) { this.id = id; }
                int id;
        }

Account[] accounts = [new Account(5), new Account(6), new Account(7)];

        foreach(acc; accounts)
        {
                task(() { writeln(acc.id); }).executeInNewThread();
        }
        
        readln();
}

Reply via email to