Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » How to close a Thread?
Re: How to close a Thread? [message #38024 is a reply to message #38022] Wed, 28 November 2012 17:05 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi NilaT

The problem is that IsOpen() does something slightly different than you think Wink
Thread docs

bool IsOpen() const
Thread represents an existing thread. Note that the thread can be already finished and not running anymore (calling to Wait in that case returns immediately).
I.e. it returns false only before the thread is started and true always after it started, regardless of the current state. Other threads have no idea about what happens elsewhere.

The only reliable way to end a thread is to finish it from within. If you want to stop all running threads, just call ShutdownThreads() and make sure that all threads (well, except the main one, ussually) check periodically state of IsShutdownThreads(). If you need to stop only one particular thread, you must create your own flag that you can set in main thread to signalize the other one to finish itself. If necessary, the thread can also report that it is closing in similar way.

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Proposal: set HttpRequest::MaxContentSize(int64)
Next Topic: Witz and map variable
Goto Forum:
  


Current Time: Fri Jul 18 06:31:43 CEST 2025

Total time taken to generate the page: 0.04347 seconds