Ok so let me see if I understand this....
I can _beginthread(
pass it a function that can not have parameters with return type of void apparently which will just be the name of the fucntion right?
Then the second number they say leave 0 it is for stack size allow windows to figure this out on it's own.
the third param... say I wanted to pass an int why are they casting int to void * wouldn't that do something weird?
Just trying to figure this out so I can say have the main thread check for incoming connections on a fd. Then let each new fd have it's own thread for inputs / outputs.
Got code from:
Multithreading Tutorial - CodeProject
Code:#include <stdio.h>
#include <windows.h>
#include <process.h> // needed for _beginthread()
void silly( void * ); // function prototype
int main()
{
// Our program's first thread starts in the main() function.
printf( "Now in the main() function.\n" );
// Let's now create our second thread and ask it to start
// in the silly() function.
_beginthread( silly, 0, (void*)12 );
// From here on there are two separate threads executing
// our one program.
// This main thread can call the silly() function if it wants to.
silly( (void*)-5 );
Sleep( 100 );
}
void silly( void *arg )
{
printf( "The silly() function was passed %d\n", (INT_PTR)arg ) ;
}