The occupants as threads
QNX SDP8.0Getting Started with the QNX OSDeveloperUser
The people living in the house are the active
objects—they're
the ones using the various rooms, watching TV, cooking, taking
showers, and so on.
We'll soon see that's how threads behave.
- Single-threaded
- If you've ever lived on your own, then you know what this is like—you know that you can do anything you want in the house at any time, because there's nobody else in the house. If you want to turn on the stereo, use the washroom, have dinner—whatever—you just go ahead and do it.
- Multi-threaded
- Things change dramatically when you add another person into the house.
Let's say you get married, so now you have a spouse living there too.
You can't just march into the washroom at any given point; you need to
check first to make sure your spouse isn't in there!
If you have two responsible adults living in a house, generally you can be reasonably lax about
security
—you know that the other adult will respect your space, won't try to set the kitchen on fire (deliberately!), and so on.Now, throw a few kids into the mix and suddenly things get a lot more interesting.
Page updated: