java left logo
java middle logo
java right logo
 

Home arrow Java SE Tips arrow java.util arrow How to implement a Queue
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4085
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to implement a Queue E-mail
User Rating: / 45
PoorBest 

This Java tip illustrates a method of implementing a Queue. Java provides LinkedList class which may be implemented as a queue. Developers may store their data in a queue and retrieve their data in First in First out(FIFO) manner.

    LinkedList queue = new LinkedList();
    
    // In queue data is added in the end
    queue.add(object);
    
    // Data is retrieved from the head of queue
    Object o = queue.removeFirst();
    
    // In case multiple threads are using a queue there is 
    // a need to synchronize methods
    queue = (LinkedList)Collections.synchronizedList(queue);


 Related Tips

 
< Prev   Next >
 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.