www.digitalmars.com         C & C++   DMDScript  

c++ - multi thread

reply Michael <Michael_member pathlink.com> writes:
How can I compile a multi thread program? Like this:

#include <cstdio>
#include <process.h>
void thread1(void* pVoid)
{
for(int i = 0; i < 100; i++)
printf("thread1\n");
}

void thread2(void* pVoid)
{
for(int i = 0; i < 50; i++)
printf("thread2\n");
}

int main()
{
_beginthread(thread1, 0, 0);
_beginthread(thread2, 0, 0);
return 0;
}

When compiling: dmc multithread
it prints:
_beginthread(thread1, 0, 0);
^
Error: undefined identifier '_beginthread'
errorlevel 1
May 14 2005
parent reply "Walter" <newshound digitalmars.com> writes:
_beginthread is defined in \dm\include\process.h. I'd check your INCLUDE and
other settings to see if perhaps you've got another process.h somewhere that
is being #include'd instead.
May 17 2005
parent Michael <Michael_member pathlink.com> writes:
In article <d6ea69$16t6$2 digitaldaemon.com>, Walter says...
_beginthread is defined in \dm\include\process.h. I'd check your INCLUDE and
other settings to see if perhaps you've got another process.h somewhere that
is being #include'd instead.
I tried to use the absolute path (#include "E:\DigitalMars\include\process.h"), but the problem remained. By the way, does dmc compile the source code into a multithread program by default? No flags needed?
May 20 2005