in reply to how to kill a thread in windows

I don't think that's possible with the current Perls (5.8.x and 5.9.3 at this time of writing):

So maybe this feature is in the most recent version of the threads module, but I doubt it, as it will likely need support in the emulation layer for Perl. One thing I can think of would be to use the Windows API to suspend and/or kill your threads via their threads->tid, but this is very unclean, as Perl also keeps track of your threads and wraps them somewhat. If you really do kill them that way, be prepared for crashes at program exit time.

Update: Changed ->pid to ->tid as BrowserUk correctly notes below

Replies are listed 'Best First'.
Re^2: how to kill a thread in windows
by BrowserUk (Patriarch) on Jun 23, 2006 at 17:22 UTC
    One thing I can think of would be to use the Windows API to suspend and/or kill your threads via their threads->pid,

    I guess you meant threads->tid. Even so, that wouldn't work as the thread id it returns is a Perl-internal id, not anything the OS would recognise. However, the cpan version of the threads module does export threads->_handle which could be used in conjunction with Win32::API to Terminate a thread, but like you, I would strongly warn against designing code to use this.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: how to kill a thread in windows
by jdhedden (Deacon) on Jul 11, 2006 at 14:43 UTC
    The threads module has been greatly improved and enhanced as of late. Signalling between threads is now supported, even on Windows. With this feature, killing a thread is now supported.

    In addition, there is a new Thread::Suspend module that is based on new threads features. It works on Windows, as well.


    Remember: There's always one more bug.