Code example for ArrayBlockingQueue

0
    private final static int QUEUE_MAX_LENGTH = 30;
 
    @Override 
    public void onCreate() { 
        super.onCreate(); 
        BlockingQueue<JSONObject> queue = new ArrayBlockingQueue<JSONObject>(QUEUE_MAX_LENGTH);
        jsonProducerThread = new JSONProducer(queue, (LocationManager) this.getSystemService(Context.LOCATION_SERVICE),
                ((TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(), this);
        consumerThread = new Consumer(queue, this, getApplicationContext());
    } 
 
    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) {
        sendMessage(getString(R.string.service_start_message));
        super.onStartCommand(intent, flags, startId);
        jsonProducerThread.startJSONProducer();
        consumerThread.startConsumer();
        return START_STICKY;
    } 
 
    @Override