+static void tst_win32(int num)
+{
+ HANDLE handles[NUM_THREADS];
+ DWORD dwThreadId[NUM_THREADS];
+ 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);
+}
+#endif
+
+#if YAZ_POSIX_THREADS
+static void tst_pthread(int num)
+{
+ pthread_t child_thread[NUM_THREADS];
+ int i, id[NUM_THREADS];
+
+ assert (num <= NUM_THREADS);
+ for (i = 0; i<num; i++)
+ {
+ id[i] = i >= 2 ? 0 : 1; /* first two are writing.. rest is reading */
+ pthread_create(&child_thread[i], 0 /* attr */, run_func, &id[i]);
+ }
+
+ for (i = 0; i<num; i++)
+ pthread_join(child_thread[i], 0);
+
+ for (i = 0; i<num; i++)
+ YAZ_CHECK(id[i] == 123);
+}
+#endif
+