Giriş
Açıklaması şöyle. LinkedList gibidir yani indeks kullanarak erişime izin vermez.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Şöyle yaparız.
Açıklaması şöyle. LinkedList gibidir yani indeks kullanarak erişime izin vermez.
constructorAn unbounded thread-safe queue based on linked nodes. This queue orders elements FIFO (first-in-first-out). The head of the queue is that element that has been on the queue the longest time. The tail of the queue is that element that has been on the queue the shortest time. New elements are inserted at the tail of the queue, and the queue retrieval operations obtain elements at the head of the queue. A ConcurrentLinkedQueue is an appropriate choice when many threads will share access to a common collection. Like most other concurrent collection implementations, this class does not permit the use of null elements. This implementation employs an efficient "wait-free" algorithm based on one described in Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms by Maged M. Michael and Michael L. Scott.
Şöyle yaparız.
ConcurrentLinkedQueue<Integer> q=new ConcurrentLinkedQueue<Integer>();
add metoduŞöyle yaparız.
int i=0;
q.add(i);
iterate metoduŞöyle yaparız.
Queue<String> globalQueue = new ConcurrentLinkedQueue<String>();
//Multiple threads can safely call globalQueue.add()...
for (String href : globalQueue) {
//do something with href
}
isEmpty metoduŞöyle yaparız.
while(!q.isEmpty()){
...
}
remove metoduŞöyle yaparız.
int value = q.remove();
Hiç yorum yok:
Yorum Gönder