|[ LiB ]|
Multithreading is a subject that people love to hate, but it is pretty much a requirement for modern computing. The way things are happening in the computing world, it looks as if multiprocessing is the wave of the future. If you look at a modern video card, you can see that it's practically a general-purpose CPU on its own, and one day the entire concept of a chip specifically dedicated to video processing may be outdated ; instead, you'll have many chips in every system, much like today's top-of-the-line four-processor workstations.
Multithreading harnesses the power of multiple processors, and it is also a virtual necessity when dealing with networked programming (even on a single processor machine). In the previous chapter, I showed you ways to poll the network system to see if there is any data available, but this method is wasteful . Wouldn't you rather have the network system tell your program, "Hey! I've got some data here!" instead of your program saying, "Anything yet? Anything yet? Anything yet?" like an annoying kid. Multithreading allows you to do this. It is an essential part of modern network programming, especially for MMOGs, which can have many thousands of open sockets at any given time.
In this chapter, you will learn to:
Understand the advantages and disadvantages of multithreading
Understand the multithreading library used in this book
Implement ThreadLib mutexes
Use demos that illustrate the concepts of the chapter
|[ LiB ]|