class PrintThread1 implements Runnable {
private static final Object LOCK = new Object();
private static int count = 0; // 计数,同时确定线程是否要加入等待队列,还是可以直接去资源队列里面去获取数据进行打印
private LinkedList<Integer> queue;
private Integer threadNo;
public PrintThread1(LinkedList<Integer> queue, Integer threadNo) {
this.threadNo = threadNo;
while (count % 3 != this.threadNo) {
} catch (InterruptedException e) {
Integer val = this.queue.poll();
System.out.println("thread-" + this.threadNo + ":" + val);