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 stop a thread that is waiting, e.g., listen()
Re: how to stop a thread that is waiting, e.g., listen() [message #11803 is a reply to message #11802] Wed, 26 September 2007 13:05 Go to previous messageGo to previous message
tvanriper is currently offline  tvanriper
Messages: 85
Registered: September 2007
Location: Germantown, MD, USA
Member
You could probably do this with a signal. Normally, threads allow you to have multiple signals at one time. You are using one of those signals right now to wait on your networking socket (or whatever you're doing)... so you could create another signal to indicate that you have some kind of message for the thread.

The message could be stored in a variable that's protected by a mutex.

When the thread gets the signal, it looks in the variable, sees that you want it to close, and then stops itself (cleaning up any variables it needs to clean up).

It's not recommended to try and forcibly close a thread, as you seem to suggest wanting to do, because this will not deallocate variables you have (implicitly or explicitly) allocated for that thread.
 
Read Message icon11.gif
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message icon5.gif
Read Message
Read Message icon9.gif
Read Message
Read Message
Read Message
Read Message icon11.gif
Read Message
Read Message
Previous Topic: GuiMT example does not calculate all divisors...
Next Topic: will implement a UDP class?
Goto Forum:
  


Current Time: Tue May 14 07:45:56 CEST 2024

Total time taken to generate the page: 0.02713 seconds