returning a value from a thread
Christopher T King
squirrel at WPI.EDU
Wed Jul 14 14:13:30 EDT 2004
On Wed, 14 Jul 2004, Jeff Shannon wrote:
> Christopher T King wrote:
>
> >Just don't forget to .join() on the thread in module1 before accessing the
> >container object! (Assuming you're using threading) I just wish Python's
> >.join() could return values, like pthread_join can.
>
> This may work if the worker thread will perform a relatively short task
> and then die *before* you access the result. But lists and dictionaries
> are not thread-safe -- if they are potentially accessed by multiple
> threads concurrently, then the behavior will be unpredictable.
That's where the .join() comes in handy (it blocks until the thread dies)
;)
More information about the Python-list
mailing list