syncUninterruptibly(); channel = null; } } finally { connectLock.unlock(); } Iterator<Packet> iter = outgoingQueue.iterator(); while (iter.hasNext()) { Packet p = iter.next(); if (p == WakeupPacket.getInstance()
不带阻塞参数打poll方法更简单,队列为空就直接返回null 2.take方法 //无法出队就傻等publicEtake()throwsInterruptedException{E x;int c=-1;finalAtomicIntegercount=this.count;finalReentrantLocktakeLock=this.takeLock;takeLock.lockInterruptibly();try{while(count.get()==0){notEmpty.await();}x=dequeue(...
publicEtake()throwsInterruptedException{E x;int c=-1;finalAtomicIntegercount=this.count;finalReentrantLocktakeLock=this.takeLock;takeLock.lockInterruptibly();try{while(count.get()==0){notEmpty.await();}x=dequeue();c=count.getAndDecrement();if(c>1)notEmpty.signal();}finally{takeLock.unlock(...