[Tutor] stopping threads ?

Kent Johnson kent37 at tds.net
Mon Nov 3 19:49:38 CET 2008


On Mon, Nov 3, 2008 at 1:14 PM, Lie Ryan <lie.1296 at gmail.com> wrote:
> On Mon, 03 Nov 2008 14:46:09 +0000, dave selby wrote:
>
>> Hi All,
>>
>> Why when I use threads in my app (I know they are evil ...lol) does it
>> not stop with ctrl-c, I have to use ctrl-z ?
>>
>> Cheers
>>
>> Dave
>
> Wonder why? Because Ctrl-C merely raises KeyboardInterrupt in the main
> thread, breaking the main thread, while leaving the other threads
> running. To interrupt a multi-threaded program, you'd need to stop all
> running threads.

If you mark the non-main threads as daemon threads then the program
will exit without stopping them.

Kent


More information about the Tutor mailing list