- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
In my code I have some thing like below
tbb::tbb_thread* m_tbbTimerThread; m_tbbTimerThread=new tbb::tbb_thread(&sFirstTimerBlocked,this);
// Above thread is spawned.
Later I want to deleted thread in different function. I am doing it as below.
if(m_tbbTimerThread!= NULL){delete m_tbbTimerThread;} m_tbbTimerThread= NULL;
Is this right way of doing. Is thread better way of doing this? Are thread delete API exists?
Thanks!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may delete the thread object only after calling join() or detach(). If you want to delete the O.S. thread, you would typically tell it to stop, e.g., by writing to an atomic<bool> that is regularly checked by the thread and interpreted as a request to return. Forcefully stopping the thread is supported by O.S. calls, but is not recommended for threads running C++ code.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page