if you have MSVC use the MSDN, borland builder has a library that has it.
if you don't have those,
unsigned long _beginthread( void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist );
Paramaters:
start_address
Start address of routine that begins execution of new thread
stack_size
Stack size for new thread or 0
arglist
Argument list to be passed to new thread or NULL
void _endthread(void)
used to terminate the thread created by begin thread.
use them like so
Code:
int counter = 0;
// this functio must be declaread in this format void myfunc(void*)
void ThreadFunc(void* v)
{
while(counter < 10000);
_endthread(); // must be called to cleanup after thread
}
main()
{
bool done = false;
// do not include the parentheses when passing the function to beginthread
_beginthread(ThreadFunc,0,NULL);
while(!done)
{
if(counter%1000)
printf("Counter:%d",counter);
}
return 0;
}
this shuld print the value of counter ten times