new Thread(() -> { try { int i = 0; int max = 1000000; while (true) { i++; queue.put(String.valueOf(ThreadLocalRandom.current().nextInt(999999999))); if (i > max) { System.out.println("结束" + i); break; } } } catch (InterruptedException e) { e.printStackTrace(); } }).start();
"Thread-1@685" prio=5 tid=0xd nid=NA waiting java.lang.Thread.State: WAITING at sun.misc.Unsafe.park(Unsafe.java:-1) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199) at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:209) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285) at com.whatakitty.learn.collections.MyQueue.signalNotEmpty(MyQueue.java:136) at com.whatakitty.learn.collections.MyQueue.put(MyQueue.java:62) at com.whatakitty.learn.collections.MyQueue.lambda$main$1(MyQueue.java:193) at com.whatakitty.learn.collections.MyQueue$$Lambda$2.1577213552.run(Unknown Source:-1) at java.lang.Thread.run(Thread.java:748)
"Thread-0@681" prio=5 tid=0xc nid=NA waiting java.lang.Thread.State: WAITING at sun.misc.Unsafe.park(Unsafe.java:-1) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199) at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:209) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285) at com.whatakitty.learn.collections.MyQueue.signalNotFull(MyQueue.java:146) at com.whatakitty.learn.collections.MyQueue.take(MyQueue.java:91) at com.whatakitty.learn.collections.MyQueue.lambda$main$0(MyQueue.java:175) at com.whatakitty.learn.collections.MyQueue$$Lambda$1.431687835.run(Unknown Source:-1) at java.lang.Thread.run(Thread.java:748)
new Thread(() -> { try { int i = 0; int max = 1000000; while (true) { i++; queue.put(String.valueOf(ThreadLocalRandom.current().nextInt(999999999))); if (i > max) { System.out.println("结束" + i); break; } } } catch (InterruptedException e) { e.printStackTrace(); } }).start();