From ca990558373e6e1f54dd36b7457b1dd25b5eb332 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Thu, 22 Apr 2004 17:54:27 +0000 Subject: Fixed thread start race condition --- cpp/src/IceUtil/Thread.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cpp/src/IceUtil/Thread.cpp') diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp index de1d907a4bc..c9704378849 100644 --- a/cpp/src/IceUtil/Thread.cpp +++ b/cpp/src/IceUtil/Thread.cpp @@ -220,6 +220,11 @@ startHook(void* arg) IceUtil::ThreadControl IceUtil::Thread::start() { + // + // Keep this alive for the duration of start + // + IceUtil::ThreadPtr keepMe = this; + IceUtil::Mutex::Lock lock(_stateMutex); if(_started) @@ -501,6 +506,11 @@ startHook(void* arg) IceUtil::ThreadControl IceUtil::Thread::start() { + // + // Keep this alive for the duration of start + // + IceUtil::ThreadPtr keepMe = this; + IceUtil::Mutex::Lock lock(_stateMutex); if(_started) -- cgit v1.2.3