package devmanuals.com; import java.util.concurrent.BlockingDeque; import java.util.concurrent.LinkedBlockingDeque; class Add implements Runnable { BlockingDeque bdq; public Add(BlockingDeque bdq) { this.bdq = bdq; } public void run() { System.out.println("Elements of deque are : "); int i; boolean bol=false; for(i=0; i<5;i++) bdq.add(i); System.out.println(bdq); System.out.println("Size of deque = "+bdq.size()); try { Thread.sleep(500); bol = bdq.add(5); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Deque after adding element : "+bdq); System.out.println("Size of deque after adding element = "+bdq.size()); System.out.println("Is the element added into the deque : "+bol); } } public class BdqAdd { public static void main(String[] args) { BlockingDeque bdq = new LinkedBlockingDeque(); Runnable a = new Add(bdq); new Thread(a).start(); try { Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } } }