test/testlock.c
changeset 2779 4436464c4f51
parent 1895 c121d94672cb
child 3578 0d1b16ee0bca
--- a/test/testlock.c	Sat Nov 22 06:59:22 2008 +0000
+++ b/test/testlock.c	Mon Nov 24 00:18:42 2008 +0000
@@ -44,8 +44,9 @@
     Uint32 id = SDL_ThreadID();
     int i;
     printf("Process %u:  Cleaning up...\n", id == mainthread ? 0 : id);
+    doterminate = 1;
     for (i = 0; i < 6; ++i)
-        SDL_KillThread(threads[i]);
+        SDL_WaitThread(threads[i], NULL);
     SDL_DestroyMutex(mutex);
     exit(sig);
 }
@@ -55,7 +56,7 @@
 {
     if (SDL_ThreadID() == mainthread)
         signal(SIGTERM, closemutex);
-    while (1) {
+    while (!doterminate) {
         printf("Process %u ready to work\n", SDL_ThreadID());
         if (SDL_mutexP(mutex) < 0) {
             fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
@@ -70,10 +71,10 @@
         }
         /* If this sleep isn't done, then threads may starve */
         SDL_Delay(10);
-        if (SDL_ThreadID() == mainthread && doterminate) {
-            printf("Process %u:  raising SIGTERM\n", SDL_ThreadID());
-            raise(SIGTERM);
-        }
+    }
+    if (SDL_ThreadID() == mainthread && doterminate) {
+        printf("Process %u:  raising SIGTERM\n", SDL_ThreadID());
+        raise(SIGTERM);
     }
     return (0);
 }