#include "stdafx.h" #undef UNICODE #include <windows.h> #include <iostream> using namespace std; class Thread { public: virtual void run () { } }; class MyThread : public Thread { public: int n; void run () { while (true) { Sleep (100); cout << "Hello from thread " << n << endl; } } }; DWORD WINAPI f (void * param) { Thread * p = (Thread *) param; p->run (); return 0; } int _tmain(int argc, _TCHAR* argv[]) { for (int i = 1; i <= 3; i++) { MyThread * t = new MyThread; t->n = i; HANDLE h; h = CreateThread (NULL, // security attr 0, // stack f, (void*) t, // function parameter 0, // flags NULL) ; // thread id if (h == NULL) cout << "Chyba" << endl; else CloseHandle (h); } cout << "Stop" << endl; char s [2]; cin.getline (s, sizeof (s)); return 0; }