in reply to returning from a thread ?
If you're using Perl threads, you shouldn't have to worry about whether it is actually implemented using processes or real threads™. That's why they're "Perl threads".
Having said that, to my knowledge, Linux is the only system where you can actually think of threads as processes, as having seperate program id's (pid's, $$). This allows modules as Thread::Signal to function in that environment. Win32 only knows about real threads and mimics fork() using threads. Other *nixes are somewhere inbetween. Some can fork() and have real threads (Solaris seems to fall in that group). But e.g. on Mac OS X (and presumably other BSD's), threads look as seperate processes, but can not be signalled.
...never-ending sub (ie it's got a while (1) loop)m how can I stop it nevertheless?
Use a shared variable in the while. So:
becomes:while (1) {
and reset the shared variable in another thread when you want to have the thread in question stop.while ($sharedvar) {
In that respect, you might also want to have a look at Thread::Queue::Monitored and/or Thread::Conveyor::Monitored.
Hope this helps.
Liz
Update:
I forgot one other way to do this. This will only work if you are running under Linux for now. Use Thread::Signal to activate a handler that will do a Thread::Exit. No nice cleanup that way, but definitely effective ;-)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: returning from a thread ?
by Foggy Bottoms (Monk) on Aug 21, 2003 at 14:03 UTC | |
by liz (Monsignor) on Aug 21, 2003 at 14:07 UTC | |
by Foggy Bottoms (Monk) on Aug 21, 2003 at 14:15 UTC | |
by liz (Monsignor) on Aug 21, 2003 at 14:24 UTC | |
by Foggy Bottoms (Monk) on Aug 21, 2003 at 15:51 UTC | |
by Foggy Bottoms (Monk) on Aug 22, 2003 at 13:46 UTC | |
| |
by bobtfish (Scribe) on Aug 21, 2003 at 17:04 UTC |