模拟简单程序代码如下:
package cn.zz.lc.test;
import java.util.LinkedList;
import java.util.Queue;
public class TestQueue {
public static void main(String[] args) throws InterruptedException {
Queue queue = new LinkedList();
for (int i = 0; i < 65; i++) {
queue.offer("queue emement:" + i);
}
System.out.println(queue.size());
String str;
int j = 1;
while (!queue.isEmpty()) {
int k = 10;
while ((str = queue.poll()) != null) {
System.out.println(str);
k--;
if (k == 0) {
break;
}
}
System.out.println("第" + j + "次提交!");
j++;
Thread.sleep(5000);
}
System.out.println("===================================");
System.out.println(queue.size());
}
}