com.app.common.thread.AsyncQueue Maven / Gradle / Ivy
The newest version!
package com.app.common.thread;
import java.util.LinkedList;
import org.slf4j.Logger;
import com.app.common.logger.AsyncSlf4jLoggerFactory;
public class AsyncQueue {
public static boolean isPrint = false;
public static int printLevel = 1;
public static int MaxSize=100;
static Logger logger = AsyncSlf4jLoggerFactory.getLogger(AsyncQueue.class);
public static void printQueueSize(String name, LinkedList queue) {
int size=queue.size();
if (isPrint) {
if (printLevel == 2) {
logger.warn("{} size:{}", name, queue.size());
} else if (printLevel == 1) {
logger.info("{} size:{}", name, queue.size());
} else if (printLevel == 0) {
logger.debug("{} size:{}", name, queue.size());
}
}
if(size>MaxSize) {
logger.warn("queues[{}:size:{}] is greater than {}", name,queue.size(), MaxSize);
}
}
}