Dne 17.10.2016 v 11:56 markov via Digitalmars-d-learn napsal(a):
Thanks.
So something like this would be helpful in core.thread?
void startThread(alias fun, P...)(P p){
new Thread({fun(p);}).start();
}
or without delegate
import std.stdio;
import core.thread;
void fun(alias a, alias
Thanks.
So something like this would be helpful in core.thread?
void startThread(alias fun, P...)(P p){
new Thread({fun(p);}).start();
}
On 10/16/2016 03:22 PM, markov wrote:
void test(string line){
...
};
void main(){
string[] list;
foreach (line; list)
new Thread({test(line);}).start();
...
}
It works in an unexpected way: In D, all those threads would close over
the same 'line' loop variable, which happens to