Possible Duplicate:
C++ multithreading tutorial
I have a project I need to deliver and were supposed to use multi-threading using WIN32 API.
I am a beginner at windows programming and I need a helpful tutorial that can help me with that, any recommendations?I'm using Visual Studio C++
As simple as it gets.
#include <windows.h>
#include <iostream>
using namespace std;
void my_function(char* parameter){
cout << parameter;
}
int main(){
char* passpointer = "hahaha";
HANDLE recvhand = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)my_function,passpointer,0,NULL);
Sleep(1000);
}
Basically
you can use the CreateThread
function just like you see it, for any simple threading. If you need more advanced help, you can ask specific addressable questions, or you can do some advanced google searching =)
Seriously, I think you are in trouble. Multithreaded programming is fairly hard, and it is unreasonable for a novice programmer to expect to get it right.
Is this homework, or are you doing it for an employer (or something else)?
精彩评论