Are min() and max() thread-safe?
Carl Banks
pavlovevidence at gmail.com
Thu Sep 17 07:02:48 EDT 2009
On Sep 16, 9:33 pm, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:
> def minmax(seq):
> result = [None, None]
> t1 = MMThread(seq, min, result, 0)
> t2 = MMThread(seq, max, result, 1)
> t1.start()
> t2.start()
> # Block until all threads are done.
> while any([t1.isAlive(), t2.isAlive()]):
> time.sleep(0)
Why not use "t1.join(); t2.join()" here? Is there any benefit to do
it this way instead?
Carl Banks
More information about the Python-list
mailing list