|
《Windows游戏编程大师技巧》(第二版)第11章(36) Sleep(100); // sleep a little to slow things down } // end for index // just return the data sent to the thread function return((DWORD)data); } // end Printer_Thread // MAIN //////////////////////////////////////////////////////// void main(void) { HANDLE thread_handle[MAX_THREADS]; // this holds the // handles to the threads DWORD thread_id[MAX_THREADS]; // this holds the ids of the threads // start with a blank line printf("\nStarting all threads...\n"); // create the thread, IRL we would check for errors for (int index=0; index<MAX_THREADS; index++) { thread_handle[index] = CreateThread(NULL, // default security 0, // default stack Printer_Thread,// use this thread function (LPVOID)index, // user data sent to thread 0, // creation flags, 0=start now. &thread_id[index]); // send id back in this var } // end for index // now enter into printing loop,
|