BorderGame
[C++] Multithreading - Versione stampabile

+- BorderGame (https://www.bordergame.it)
+-- Forum: Programmazione (/Forum-Programmazione--158)
+--- Forum: Programmazione (/Forum-Programmazione)
+---- Forum: C, C# & C++ (/Forum-C-C-C)
+---- Discussione: [C++] Multithreading (/Thread-C-Multithreading)



[C++] Multithreading - Ð3V!L - 13-11-2012 04:15 PM

Ecco a voi

#include <windows.h>
#include <iostream>

HANDLE thread1, thread2;
DWORD thrdid;

DWORD WINAPI thr1(LPVOID param)
{
while(1) std::cout << "thread 1" << std::endl;
}

DWORD WINAPI thr2(LPVOID param)
{
while(1) std::cout << "thread 2" << std::endl;
}

int main()
{
thread1 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)thr1,0,0,&thrdid);
thread2 = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)thr2,0,0,&thrdid);

system("pause");
return 0;
}

Per chi non sa cos'è il multithreading esiste wikipedia ^^ http://it.wikipedia.org/wiki/Multithreading