|
- Single threaded systems use an approach called an event loop with pooling. In this model, a single thread of control runs in an infinite loop, polling a single event queue to decide what to do next.
- Once this polling mechanism returns with, say a signal that a network file is ready to be read, then the event loop dispatches control to the appropriate event handler. Until this event handler returns, nothing else can happen in the system. This wastes CPU time. It can also result in one part of a program dominating the system and preventing other events from being processed.
- In general, in a single-threaded environment, with a thread blocks because it is waiting for some resource, the entire program stops running.
- The benefit of multithreading is that the main loop/polling mechanism is eliminated. One thread can pause without stopping other parts of the program.
|