Python threading tutorial?
hg
hansgeunsmeyer at earthlink.net
Sat Jan 4 12:43:32 EST 2003
Gerrit Holl <gerrit at nl.linux.org> wrote in message news:<mailman.1041679867.22000.python-list at python.org>...
> Hello,
>
> I am looking for a tutorial on threading using Python. I do know Python, but
> I don't know threading.
Aahz has a slideshow plus example scripts:
http://starship.python.net/crew/aahz/OSCON2001/index.html
> I don't really understand threading. If I have multiple threads, can these
> threads interact?
Yes. They can share data, communicate in various ways, one thread can
start another, wait for another, etc.
> When should I use threads, and when shouldn't I? In which
> cases are threads useful, and in which cases does the phrase on Regular
> Expressions apply ("problem -> regex -> two problems")?
>
> My case is an exercise application in which multiple object are randomly
> wandering through a field, but when they meet they interact and go in
> opposite directions. All those objects will be class instances and need to
> "live" seperately, only interacting when they meet. Can threads help me in
> this particular problem, or do threads have (very) different uses?
I think this problem is a natural problem for threads. I mean, using
threads for this problem can make your program shorter and clearer.
You're simulating a bunch of independent but identical agents, so each
one could live in its own thread.
Hans
More information about the Python-list
mailing list