[MUD-Dev] Question about threads.

Caliban Tiresias Darklock caliban at darklock.com
Thu Feb 14 13:17:15 CET 2002


From: "Anderson, David" <david.anderson at tfp.com>

> I can think of plenty of problems by using threads (IE, the Dragon
> walking through a door that just closed).  What would be the
> benefits?  What are the reasons I should use threads?  And even
> better, if I should use threads, what would be their purpose?

Generally speaking, I use threads for anything time consuming and
stupid that I don't feel like doing. Any given server has a stack of
about fifty jobs, and only a few of them are really critical. The
rest of them can happen a little slower or even be skipped now and
then. I have a thread dedicated to nothing but processing text, for
example -- it reads stuff from sockets and writes stuff to sockets,
and that's ALL it does. It doesn't do any of the network connection
or database maintenance or anything, it just happily and stupidly
pumps stuff in and out of the socket. It doesn't know or care what
that stuff is, and may as well be shoveling manure out of the
stables -- it's just moving stuff as fast as it can, and doesn't
look too closely at it or think too much about it.

Most of the really awful thread problems I hear about are efforts to
set up little "committees" of threads, each with equivalent
authority and stature.  I don't do that. I brand one thread "boss
man", and everyone else is a peon.  I don't trust them, and I don't
expect much from them. I just tell them to run little errands here
and there, so I don't have to be distracted by the small stuff. If I
can reliably hire some dork at minimum wage to do something, and he
wouldn't need anyone else's help to do it, then I hire that dork to
do it for me instead of doing it myself -- and that's the way I view
threads. Each additional thread I spawn is some dork working for
minimum wage. He has no initiative and no judgment, and can't be
expected to do anything too terribly important. But for the server's
equivalent of burger flipping and floor mopping, he's just perfect.

YMMV. ;)


_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list