Passing parameters to thread functions

D_Starter via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 15 07:41:14 PDT 2015


> On Saturday, 15 August 2015 at 12:49:47 UTC, anonymous wrote:
>
> You can pass a delegate that calls the function:
> ----
> uint val = 7;
> auto thread1 = new Thread({thread_proc(val);}).start();
> ----
>

For the sake of simplicity this is perfectly fine and works. Data 
races seem possible but can be avoided with the use of distinct 
variables and waiting for the threads to finish.


More information about the Digitalmars-d mailing list