### Question:
MulBlockingQueue { @SuppressWarnings("unchecked") public List<E> poll(BitSet queueIds) throws InterruptedException { ArrayList<E> re = new ArrayList<>(queueIds.cardinality()); for (int id = queueIds.nextSetBit(0); id >= 0; id = queueIds.nextSetBit(id + 1)) { DalQueue dalqueue = queues[id]; if (dalqueue == null) { unReadyQueue(id, dalqueue); continue; } E x = (E) dalqueue.queue.poll(); if (x != null) { dalqueue.count.getAndDecrement(); dalqueue.modCount.getAndIncrement(); re.add(x); } if (dalqueue.count.get() == 0) { unReadyQueue(id, dalqueue); } } return re; } MulBlockingQueue(int maxQueueNumber); int size(int queueId); String queueName(int queueId); void put(E e, int queueId); @SuppressWarnings("unchecked") List<E> poll(BitSet queueIds); @SuppressWarnings("unchecked") List<E> pollOverDraw(BitSet queueIds); List<E> poll(long timeout, TimeUnit unit, BitSet queueIds); List<E> take(BitSet queueIds); synchronized int register(String queueName); synchronized void unregister(int id); int queueSize(); @Override String toString(); BitSet getReadyQueueIds(); long getModCount(int queueId);  }### Answer:
@Test public void poll() throws InterruptedException { MulBlockingQueue<Payload> mq = new MulBlockingQueue<>(1024); BitSet indexs = new BitSet(2); indexs.set(mq.register("eosgroup1")); indexs.set(mq.register("eosgroup2")); List<Payload> packets = mq.poll(indexs); Assert.assertTrue(packets.isEmpty()); mq.put(new Payload(0, "p01"), 0); mq.put(new Payload(0, "p02"), 0); mq.put(new Payload(1, "p11"), 1); packets = mq.poll(indexs); Assert.assertEquals(packets.get(0).data, "p01"); Assert.assertEquals(packets.get(1).data, "p11"); packets = mq.poll(indexs); Assert.assertEquals(packets.get(0).data, "p02"); mq.put(new Payload(0, "p03"), 0); indexs.clear(0); packets = mq.poll(indexs); Assert.assertTrue(packets.isEmpty()); indexs.set(0); indexs.clear(1); mq.poll(indexs); mq.poll(indexs); mq.poll(indexs); long start = System.currentTimeMillis(); indexs.set(0); mq.poll(200, TimeUnit.MILLISECONDS, indexs); long end = System.currentTimeMillis(); Assert.assertTrue((end - start) >= 200); }