Home » Java » Blocking

Blocking

package com.ctrip.ctripimapp.listener;
import com.ctrip.ctripimapp.presenter.LoginPresenter;
import org.jivesoftware.smack.packet.Message;
import java.util.concurrent.ArrayBlockingQueue;
/**
* Created by zhangoceansoft on 16/4/27.

public, class, BlockingQueue, extends, ArrayBlockingQueue {
/**
* defines the maximum number of messages in the queue buffer pool. If this value is reached, then the queue check will continue when the wait is detected below this value

, private, static, Integer, offerMaxQueue,, =, 2000;
private, static, BlockingQueue, instance, ;
private, static, int, capacity, ;
private, BlockingQueue (int, capacity) {
super (capacity);
BlockingQueue.capacity=capacity;
}
/**
* the only way to provide access to outside programs is to access blocked queues
* @return returns the only blocked queue object

, public, static, BlockingQueue, getInstance () {
if, (instance, ==, >null, synchronized, (BlockingQueue.class) {
if, (instance, ==, >null, instance, =, new, BlockingQueue (offerMaxQueue);
}
}
}
return instance;
}
}

Latest