Thread creation state

I am creating a boost thread, how to know in which state it is created. I have a code snippet that is waiting always in the thread creatin functon istelf. Where as i tried with some boost samples, they are working amazingly perfect. This is how my code snippet looks like typedef boost::mutex::scoped_lock lock; class testCommand { static void threadfunc() { testCommand *testObj = mMapCommand[mObjID]; testObj->processthread(); }; static map< int mObjID, testCommand*> mMapCommand; private: void createthread() { mThread = new boost::thread(&testCommand::threadfunc); } void processthread() { lock lk(mMutex); mCondition.wait(lk); //// Some Action }; void runthread() { lock lk(mMutex); mCondition.notify_one(); }; public: static int mObjID; boost::thread *mThread; boost::condition mCondition; boost::mutex mMutex; }; The newly created thread is waiting at the following location forever, by the time i get a chance to execute the new thread is greatly delayed. NTDLL! 77f8856e() boost::detail::thread::lock_opsboost::mutex::unlock(boost::mutex & {...}) line 49 boost::detail::thread::scoped_lockboost::mutex::unlock() line 85 + 11 bytes boost::detail::thread::scoped_lockboost::mutex::~scoped_lockboost::mutex () line 74 `anonymous namespace'::thread_param::started() line 47 + 15 bytes thread_proxy(void * 0x0012fd74) line 71 _threadstartex(void * 0x00961040) line 212 + 13 bytes KERNEL32! 7c57b382() It sounds like i am missing something here. The queries here are 1. why it is waiting at the above specified line forever ? 2. Where can i get few worth thread samples done using boost::thread Regards Janardhan

It would be a lot easier to help if you could post a complete,
compilable example that demonstrates the problem. Also, it would be
useful to know whether you are using the Win32, pthread, or Mac
implementation of Boost.Thread.
Thanks,
Mike
I am creating a boost thread, how to know in which state it is created. I have a code snippet that is waiting always in the thread creatin functon istelf. Where as i tried with some boost samples, they are working amazingly perfect. This is how my code snippet looks like
typedef boost::mutex::scoped_lock lock; class testCommand { static void threadfunc() { testCommand *testObj = mMapCommand[mObjID]; testObj->processthread(); };
static map< int mObjID, testCommand*> mMapCommand; private: void createthread() { mThread = new boost::thread(&testCommand::threadfunc); } void processthread() { lock lk(mMutex); mCondition.wait(lk); //// Some Action };
void runthread() { lock lk(mMutex); mCondition.notify_one(); };
public: static int mObjID; boost::thread *mThread; boost::condition mCondition; boost::mutex mMutex; };
The newly created thread is waiting at the following location forever, by the time i get a chance to execute the new thread is greatly delayed.
NTDLL! 77f8856e() boost::detail::thread::lock_opsboost::mutex::unlock(boost::mutex & {...}) line 49 boost::detail::thread::scoped_lockboost::mutex::unlock() line 85 + 11 bytes
boost::detail::thread::scoped_lockboost::mutex::~scoped_lock
() line 74 `anonymous namespace'::thread_param::started() line 47 + 15 bytes thread_proxy(void * 0x0012fd74) line 71 _threadstartex(void * 0x00961040) line 212 + 13 bytes KERNEL32! 7c57b382()
It sounds like i am missing something here. The queries here are 1. why it is waiting at the above specified line forever ? 2. Where can i get few worth thread samples done using boost::thread
Regards Janardhan
participants (2)
-
janardhan.gupthaļ¼ efi.com
-
Michael Glassford