in reply to Exiting a script with an 'infinitely looping' thread
if I have a thread that never exists, what is the cleanest way to shut down the main script?
Three ways
When the main thread terminates, you won't get the warning.
The disadvantage of this is that you need to ensure that and reads or attaches in your never-ending thread timeout occasionally, otherwise you will never check the shared flag until you receive something.
That means using non-blocking IO for sockets.
More complicated and no real advantage over using a shared flag, as the thread handler won't respond to the kill signal if it is processing a blocking opcode like read or recv.
Which is more appropriate to your situation will depend upon how your app is currently coded?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Exiting a script with an 'infinitely looping' thread
by markseger (Beadle) on Nov 24, 2008 at 15:00 UTC | |
by BrowserUk (Patriarch) on Nov 24, 2008 at 15:07 UTC | |
by markseger (Beadle) on Nov 24, 2008 at 15:15 UTC | |
by BrowserUk (Patriarch) on Nov 24, 2008 at 15:27 UTC | |
by ikegami (Patriarch) on Nov 24, 2008 at 16:21 UTC | |
| |
by markseger (Beadle) on Nov 24, 2008 at 15:59 UTC | |
| |
by ikegami (Patriarch) on Nov 24, 2008 at 16:12 UTC |