Java Reference
In-Depth Information
first in, first out or FIFO fashion. Items are removed in the same order in which they
have been added.
There are many uses of queues and stacks in computer science. The Java graphical
user interface system keeps an event queue of all events, such as mouse and keyboard
events. The events are inserted into the queue whenever the operating system notifies
the application of the event. Another thread of control removes them from the queue
and passes them to the appropriate event listeners. Another example is a print queue.
A printer may be accessed by several applications, perhaps running on different
computers. If each of the applications tried to access the printer at the same time, the
printout would be garbled. Instead, each application places all bytes that need to be
sent to the printer into a file and inserts that file into the print queue. When the printer
is done printing one file, it retrieves the next one from the queue. Therefore, print jobs
are printed using the Ȓfirst in, first outȓ rule, which is a fair arrangement for users of
the shared printer.
Figure 12
A Stack of Topics
686
Search WWH ::




Custom Search