Re: A beginner's question on thread
From: Aurelio Martin (amartin_at_wpsnetwork.com)
Date: 04/06/04
- Next message: Erik Heneryd: "Re: slightly OT: BUT NEEDs to be said"
- Previous message: Ralf Muschall: "Re: [maybe OT] Making posters"
- In reply to: Timothy Wu: "A beginner's question on thread"
- Next in thread: Timothy Wu: "Re: A beginner's question on thread"
- Reply: Timothy Wu: "Re: A beginner's question on thread"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 06 Apr 2004 10:31:31 +0200
Timothy Wu wrote:
> I'm writing a small utility that listens for socket connections, and
> also repond to user inputs via a text menu selection.
>
> In order to respond to both the user and the incoming connections I
> figure I need to use thread.
>
> I think I would use the main thread to handle the menu and spawn a
> thread which listens on a socket.
>
> Now my question is, how do I terminate the server thread if user wants
> to exit the application? If the server just sit there and listen the
> thread would never terminate by itself. What kind of inter-thread
> communications are available and where would I find info/tutorial on that?
>
> Timothy
>
Well, when the user wants to exit, the main thread could open a socket
connection to the server thread, and send a special message telling it
to stop.
The server thread would have to distinguish between normal connections
from clients and special connections from the main thread.
Hope this helps
Aurelio
- Next message: Erik Heneryd: "Re: slightly OT: BUT NEEDs to be said"
- Previous message: Ralf Muschall: "Re: [maybe OT] Making posters"
- In reply to: Timothy Wu: "A beginner's question on thread"
- Next in thread: Timothy Wu: "Re: A beginner's question on thread"
- Reply: Timothy Wu: "Re: A beginner's question on thread"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|