All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.jfunc.common.thread.conpro.QueueHolder Maven / Gradle / Ivy

There is a newer version: 1.8.5
Show newest version
package top.jfunc.common.thread.conpro;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BlockingQueue;

/**
 * @author xiongshiyan
 * 通用的阻塞队列保持者,通过名字保存和获取
 */
public class QueueHolder {
    private static Map blockingQueueMap = new HashMap<>();
    public static  void put(String pipelineName , BlockingQueue blockingQueue){
        blockingQueueMap.put(pipelineName , blockingQueue);
    }
    public static  BlockingQueue getBlockingQueue(String pipelineName) {
        if(null == pipelineName || "".equals(pipelineName)){
            throw new IllegalArgumentException(" pipelineName 不能为空 ");
        }
        BlockingQueue blockingQueue = blockingQueueMap.get(pipelineName);
        if(null == blockingQueue){
            throw new IllegalStateException(pipelineName + " 对应的队列不存在 ...");
        }
        return blockingQueue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy