Back to project page AndroidImageCache.
The source code is released under:
Przemys?aw Jakubczyk Polidea Sp. z o.o. Copyright (c) 2012 All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the follo...
If you think the Android project AndroidImageCache listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package pl.polidea.utils; /* w w w .j av a 2 s. c o m*/ import java.util.concurrent.TimeUnit; import pl.polidea.thridparty.LinkedBlockingDeque; /** * @author Przemys?aw Jakubczyk <przemyslaw.jakubczyk@pl.polidea.pl> */ public class StackBlockingDeque extends LinkedBlockingDeque<Runnable> { private static final long serialVersionUID = 1635542918696298694L; public StackBlockingDeque() { super(); } public StackBlockingDeque(int capacity) { super(capacity); } @Override public boolean offer(Runnable runnable) { if (contains(runnable)) { return false; } if (remainingCapacity() > 0) { return super.offer(runnable); } else { pollFirst(); return super.offer(runnable); } } @Override public Runnable poll() { return super.pollLast(); } @Override public Runnable take() throws InterruptedException { return super.takeLast(); } @Override public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException { return super.pollLast(timeout, unit); } }