Index: trunk/psLib/src/sys/psThread.c
===================================================================
--- trunk/psLib/src/sys/psThread.c	(revision 28400)
+++ trunk/psLib/src/sys/psThread.c	(revision 28402)
@@ -38,8 +38,8 @@
 static psList *pending = NULL;          // queue of pending jobs
 static psList *done = NULL;             // queue of done jobs
+static pthread_t *threads = NULL;       // array of the POSIX thread handles
 static psArray *pool = NULL;            // array of defined threads
 static psHash *tasks = NULL;            // List of defined tasks
 static psArray *tsd = NULL;             // Thread-specific data
-
 
 /***** basic thread functions *****/
@@ -265,5 +265,5 @@
 bool psThreadPoolInit(int nThreads)
 {
-    if (pool) {
+    if (pool || threads) {
         psAbort("psThreadsInit already called");
     }
@@ -276,9 +276,10 @@
 
     pool = psArrayAlloc(nThreads);
+    threads = psAlloc(nThreads * sizeof(pthread_t));
     for (int i = 0; i < nThreads; i++) {
-        psThread *thread = psThreadAlloc(); // Thread for pool
-        int success = pthread_create(&thread->pt, NULL, psThreadLauncher, thread);
-        psAssert(!success, "Unable to start thread");
-        pool->data[i] = thread;
+        psThread *thread = pool->data[i] = psThreadAlloc(); // Thread for pool
+        if (!pthread_create(&threads[i], NULL, psThreadLauncher, thread)) {
+            psAbort("Unable to create thread");
+        }
     }
     return true;
@@ -376,4 +377,7 @@
     pool = NULL;
 
+    psFree(threads);
+    threads = NULL;
+
     psFree(tasks);
     tasks = NULL;
