package devmanuals.com; import java.util.concurrent.LinkedBlockingQueue; public class LinkedBlockingQueueDemo { public static void main(String args[]) { LinkedBlockingQueue lbq = new LinkedBlockingQueue(); lbq.add("A"); lbq.add("B"); lbq.add("C"); lbq.add("D"); lbq.add("E"); System.out.println("Elements of 1st queue = " + lbq); LinkedBlockingQueue lbq1 = new LinkedBlockingQueue(10); lbq1.offer(1); // drainTo() method int i = lbq.drainTo(lbq1); System.out .println(i + " elements are removed from 1st queue and add to the 2nd queue."); System.out.println("Therefore elements of 2nd queue = " + lbq1); // remainingCapacity() method int i1 = lbq1.remainingCapacity(); System.out .println("The remaining element that can be inserted into 2nd queue = " + i1); } }