I had nothing todo today, so I made a quick google search, and it came up with this.
http://www.cswl.com/whiteppr/white/multithreading.html
I dont know if it will be usefull, but it might be.
I also found
this article but since it's in danish I don't think it will be of much use to you, altho The basic multithreadded "hello world" example is:
Code:
#include <iostream>
#include <string>
#if defined(__linux__)
// Under *nix every threads are
// handled in the pthread.h header
#include <pthread.h>
// And sleep() is in the unistde.h
#include <unistd.h>
#define SLEEP(x) sleep(x)
#elif defined(_WIN32)
// under windows nearly every functionality
// is placed in windows.h even threadding
#include <windows.h>
#define SLEEP(x) Sleep(1000*x)
#endif
using namespace std;
// The threads will run as long as this is true
bool running = true;
#if defined(__linux__)
// This is the thread definition for *nix
void * threadProcedure(void * parameter)
#elif defined(_WIN32)
// And this is the defiition for windows
DWORD WINAPI threadProcedure(LPVOID parameter)
#endif
{
string * str = (string*)parameter;
while(running)
{
cout << (*str);
cout.flush();
SLEEP(1);
}
return 0;
}
int main(int argc, char ** argv)
{
string hello("Hello ");
string world("World ");
#if defined(__linux__)
pthread_t helloThread, worldThread;
// Start the thread which writes "Hello"
pthread_create(&helloThread,NULL,threadProcedure,&hello);
// Start the thread which writes "World"
pthread_create(&worldThread,NULL,threadProcedure,&world);
#elif defined(_WIN32)
HANDLE helloThread, worldThread;
// Start the thread which writes "Hello"
helloThread = CreateThread(NULL,0,threadProcedure,&hello,0,NULL);
// Start the thread which writes "World"
worldThread = CreateThread(NULL,0,threadProcedure,&world,0,NULL);
#endif
SLEEP(10);
// Time to stop the threads
running = false;
#if defined(__linux__)
// Wait for the "hello" thread to stop
pthread_join(helloThread,NULL);
// wait for the "world" thread to stop
pthread_join(worldThread,NULL);
#elif defined(_WIN32)
// Wait for the "hello" thread to stop
WaitForSingleObject(helloThread,INFINITE);
// Wait for the "world" thread to stop
WaitForSingleObject(worldThread,INFINITE);
#endif
return 0;
} So if you're familliar with reading code, you might be able to figureout how to extend it to be used with what you want.
Since there is nothing within the Windows API, which provides the fork()/dup()/execp() calls you'd normaly use under *nix, I am stumped, as to how you would complete that task.
But perhaps the
msdn library will reveal something, after a few hundred hours of scavenging through it.