Package java.util.concurrent

Examples of java.util.concurrent.BlockingQueue.drainTo()


        BlockingQueue q = new SharedConcurrentBlockingObjectQueue<Integer>(SIZE * 2, Integer.class);
        for (int i = 0; i < SIZE + 2; ++i) {
            for (int j = 0; j < SIZE; j++)
                assertTrue(q.offer(new Integer(j)));
            ArrayList l = new ArrayList();
            q.drainTo(l, i);
            int k = (i < SIZE) ? i : SIZE;
            assertEquals(k, l.size());
            assertEquals(SIZE - k, q.size());
            for (int j = 0; j < k; ++j)
                assertEquals(l.get(j), new Integer(j));
View Full Code Here


    BlockingQueue newQueue = QueuesHolder.getQueue(queueName);
    task.start();

    List list = new ArrayList();
    newQueue.drainTo(list);

    assertEquals(2, list.size());
    assertEquals(date1, list.get(0));

    //判断存在持久化文件
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.