Philip Smith a écrit :
Hi
I am fairly new to Python threading and my needs are simple(!)
I want to establish a number of threads each of which work on the same
computationally intensive problem in different ways.
I am using the thread module rather than the threading module.
My problem is I can't see how (when one thread completes) to ensure that the
other threads terminate immediately.
Appreciate some simple advice
Phil
With Python's threads, you have to handle this kindd a feature yourself.
For example, you can create a single object containing a boolean set to
False by default. When one of your algorithm finishes, the boolean is
set to True. All your algorithm should regularly test this boolean and
exit if it is True ! Note that the boolean has to be inside another
object because Boolean types is not mutable. Now, if you really want to
be able to "kill" your threads, you will need another thread interface.
For example, Qt threads allows that ... and WxPython offers you some
functions to do exactly what I described.
Pierre