producer and consumer using blocking queue in java code example
Example: java blocking queue
//create ArrayBlockingQueue with a capacity of 2 (maximum 2 elements)
BlockingQueue<Integer> queue=new ArrayBlockingQueue<>(2);
queue.add(1337);//add an element
int i=queue.take();//take an element