Veikka said:
Hello,
J2SE 5.0 has a lot's of new classes considering multithreading.
What is the best class to implement queue in FirstComesFirstServed model?
The API refers to these as FIFO (first in first out) queues.
Any sample code arapund?
Cheers!
Have you looked at the API for the Queue interface? It states several
implementations of Queues: if you look at each of those classes, you'll
probably find one that suits your needs.
Queues are part of the Collections interface, which has been reworked to
accomodate Queues and other new features of J2SE 5.0. The Java Tutorial
"trail" (chapter) about Collections has also been updated to reflect Queues.
You can find the updated trail here:
http://java.sun.com/docs/books/tutorial/collections/. There is a bit of
sample code for working with a LinkedList implementation of a Queue in the
Queue interface topic on this page:
http://java.sun.com/docs/books/tutorial/collections/interfaces/queue.html.
However, you should probably read the other pages in that trail that refer
to Queues, not just jump to this page and read it out of context.
Rhino