[Tutor] Communication between threads

James jtp at nc.rr.com
Wed Jul 30 22:59:02 CEST 2008


All,

I'm looking for some thoughts on how two separate threads can
communicate in Python. From what I've read in a few Python books,
sharing data between threads can be done by writing and reading a
global variable in the parent of both threads. Is this the "best" way?
Is it the *only* way?

Also, any thoughts on how to best use "notify()"? I've found very
little documentation on how to "best" use notify() when dealing with
multiple threads. (many of the documents I've found explain how to use
notifyAll(), but I'm unsure "broadcasting" a message to all threads
like that is the best way to deal with a problem)

Sorry this question is so broad; threading (properly) seems to be a
complex subject and it seems I'm in over my head. I've read tons of
documents, however, and am still rather unclear about all the tiny
parts of the big picture.

Thoughts? :)

Thanks!
-j


More information about the Tutor mailing list