Client/server chat program
Jonathan Gardner
jgardn at alumni.washington.edu
Mon Dec 10 22:44:33 EST 2001
On Tuesday 11 December 2001 07:18 am, Paul Rubin wrote:
> The usual way to do this is use separate threads for reading input and
> displaying messages.
Errr... not necessarily. Note that this is a chat program - you'll want the
seperate threads to work with each other. I find it easier to program this
sort of thing with only one thread and one process that sees what can be done
and does it without blocking. As a semi-experienced thread developer, I know
that in the end, it's better to try and avoid threads whenever possible,
unless they are almost completely independent of each other. (ie, in games,
one thread to do the ai, one thread to do the rendering, one thread to do the
game logic makes sense, because they don't really communicate with each
other, except for when they start and when they end.)
Something like a web-server, where two HTTP connections don't have to know
about each other - is perfect for giving each connection a thread or a
process to call their own.
Jonathan
More information about the Python-list
mailing list