Java tutorial
//package com.java2s; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; public class Main { public static BlockingQueue<Runnable> makeQueue(Integer capacity) { if ((capacity == null) || (capacity <= 0) || (capacity == Integer.MAX_VALUE)) { return new LinkedBlockingQueue<Runnable>(); } else { return new ArrayBlockingQueue<Runnable>(capacity); } } }