package com.neutron.t22;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* 单向和双向队列
*/
public class T224Queue {
public static void main(String[] args) {
// 单向队列
Queue<String> queue = new ConcurrentLinkedQueue<>();
// 双向队列
Queue<String> deque = new ConcurrentLinkedDeque<>();
for (int i = 0; i < 10; i++) {
queue.offer("a" + i); // 等价于add
}
System.out.println("list size:" + queue.size());
System.out.println(queue.poll()); // get and remove
System.out.println("list size:" + queue.size());
System.out.println(queue.peek()); // get not remove
System.out.println("list size:" + queue.size());
}
}