- int i, id[NUM_THREADS];
-
- assert (num <= NUM_THREADS);
- for (i = 0; i<num; i++)
- {
- void *pData = &id[i];
- id[i] = i >= 2 ? 0 : 1; /* first two are writing.. rest is reading */
- handles[i] = CreateThread(
- NULL, /* default security attributes */
- 0, /* use default stack size */
- ThreadProc, /* thread function */
- pData, /* argument to thread function */
- 0, /* use default creation flags */
- &dwThreadId[i]); /* returns the thread identifier */
- }
- /* join */
- WaitForMultipleObjects(num, handles, TRUE, INFINITE);
-}