Hey there,

I'm in the process of learning D, switching from C/C++ and Pascal. In this I've come across multithreading capabilities.

What I'm trying to achieve is to create a thread, call a thread function with parameters and have the thread return something. Like this:

[CODE]
import core.thread;

void thread_proc(ref uint var)
{
    uint v = var << 1;
    var = v;
}

int main()
{
    uint var = 7;
auto thread1 = new Thread(&thread_proc, val).start(); /* similar to C++ STL */
    thread1.join();

    return 0;
}
[/CODE]

You might have guessed...this won't work. So how do I pass parameters to thread functions? I haven't found anything useful on the library description so far.

I've already learned that using shared global variables does work, but that's not what I want.

Reply via email to