Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.TimeUnit; import java.util.concurrent.LinkedBlockingDeque; public class LinkedBlockingDequeOfferExample2 { public static void main(String[] args) throws InterruptedException { int capacity =5; LinkedBlockingDeque
queue = new LinkedBlockingDeque
(capacity); queue.add("Albert"); queue.add("Christeena"); queue.add("Aviral"); queue.add("Pratik"); //Inserts the element at the tail of queue,waiting up to the specified waiting time. queue.offer("Janak",1000, TimeUnit.MILLISECONDS); for(String xyz:queue){ System.out.println(xyz); } } }
Output