diff --git a/src/ibmras/common/port/aix/Thread.cpp b/src/ibmras/common/port/aix/Thread.cpp index 3fde9b0..c77d51b 100644 --- a/src/ibmras/common/port/aix/Thread.cpp +++ b/src/ibmras/common/port/aix/Thread.cpp @@ -132,9 +132,12 @@ void stopAllThreads() { // wake currently sleeping threads condBroadcast(); while (!threadMap.empty()) { - pthread_cancel(threadMap.top()); + pthread_t top = threadMap.top(); + pthread_cancel(top); //wait for the thread to stop - pthread_join(threadMap.top(), NULL); + pthread_mutex_unlock(&threadMapMux); + pthread_join(top, NULL); + pthread_mutex_lock(&threadMapMux); threadMap.pop(); } pthread_mutex_unlock(&threadMapMux); diff --git a/src/ibmras/common/port/linux/Thread.cpp b/src/ibmras/common/port/linux/Thread.cpp index c46b3e2..f298e3e 100644 --- a/src/ibmras/common/port/linux/Thread.cpp +++ b/src/ibmras/common/port/linux/Thread.cpp @@ -130,9 +130,12 @@ void stopAllThreads() { // wake currently sleeping threads condBroadcast(); while (!threadMap.empty()) { - pthread_cancel(threadMap.top()); + pthread_t top = threadMap.top(); + pthread_cancel(top); //wait for the thread to stop - pthread_join(threadMap.top(), NULL); + pthread_mutex_unlock(&threadMapMux); + pthread_join(top, NULL); + pthread_mutex_lock(&threadMapMux); threadMap.pop(); } pthread_mutex_unlock(&threadMapMux); diff --git a/src/ibmras/common/port/osx/Thread.cpp b/src/ibmras/common/port/osx/Thread.cpp index 5da712b..9fe1915 100644 --- a/src/ibmras/common/port/osx/Thread.cpp +++ b/src/ibmras/common/port/osx/Thread.cpp @@ -143,9 +143,12 @@ void stopAllThreads() { condBroadcast(); /* while (!threadMap.empty()) { - pthread_cancel(threadMap.top()); + pthread_t top = threadMap.top(); + pthread_cancel(top); //wait for the thread to stop - pthread_join(threadMap.top(), NULL); + pthread_mutex_unlock(&threadMapMux); + pthread_join(top, NULL); + pthread_mutex_lock(&threadMapMux); threadMap.pop(); } */