#include #include #include #include static void *test_thread(void *arg) { long timeout = rand(); timeout %= 1000; timeout += 100; Sleep(timeout); ExitThread(0); return NULL; } static int start_threads(DWORD count, HANDLE *threads) { DWORD i; for (i=0; i (WAIT_OBJECT_0 + THREADS))) { printf("WaitForMultipleObjects INFINITE failed\n"); rc = -1; } if (WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE) != WAIT_OBJECT_0) { printf("WaitForMultipleObjects bWaitAll, INFINITE failed\n"); rc = -1; } if (close_threads(THREADS, threads)) return -1; if (rc) return rc; /* WaitOne, timeout */ if (start_threads(THREADS, threads)) return -1; if (WaitForMultipleObjects(THREADS, threads, FALSE, 50) != WAIT_TIMEOUT) { printf("WaitForMultipleObjects timeout 50 failed\n"); rc = -1; } if (WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE) != WAIT_OBJECT_0) { printf("WaitForMultipleObjects bWaitAll, INFINITE failed\n"); rc = -1; } if (close_threads(THREADS, threads)) return -1; /* WaitOne, timeout, multiple joins */ if (start_threads(THREADS, threads)) return -1; for (i=0; i