
extension.lang.EvictingBlockingQueue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of extension-lang Show documentation
Show all versions of extension-lang Show documentation
Utility classes for the JDK
The newest version!
package extension.lang;
import java.util.concurrent.ArrayBlockingQueue;
public final class EvictingBlockingQueue {
private final int capacity;
private final ArrayBlockingQueue queue;
public EvictingBlockingQueue(final int capacity) {
this.queue = new ArrayBlockingQueue<>(capacity+10);
this.capacity = capacity;
}
public T take() throws InterruptedException {
return queue.take();
}
public void offer(final T object) {
if (queue.size() >= capacity)
queue.poll();
queue.offer(object);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy