Diez B. Roggisch wrote:[color=blue]
> Leon wrote:
>
>[color=green]
>>if class A(
>>use threading,threa d module
>>) to produce 100 thread,how to drop its (100 thread) when its running[/color]
>
>
> By exiting. There is no other way to stop a thread by force.[/color]
Note that even trying to exit won't work, if the threads are not
marked as "daemon" threads... Only by calling .setDaemon(True ) on
the threads before they are started will you be able to terminate
them all just by exiting.
Leon wrote:[color=blue]
> if class A(
> use threading,threa d module
> ) to produce 100 thread,how to drop its (100 thread) when its running[/color]
As Roggisch suggests, the cleanest way is if the thread kills itself
once signaled by an exit condition. However, there is a non-orthodox way
of pseudo-forcibly killing threads by catching the kill signal in a
traceback. This method is summed up in Connelly Barnes's informal
KThread module:
Comment