queue first when urgent

This commit is contained in:
Athou
2013-06-22 22:32:57 +02:00
parent d7ab27a147
commit a2a88e85c4

View File

@@ -75,7 +75,19 @@ public class FeedRefreshUpdater {
locks = Striped.lazyWeakLock(threads * 100000);
pool = new ThreadPoolExecutor(threads, threads, 0,
TimeUnit.MILLISECONDS,
queue = new LinkedBlockingDeque<Runnable>(500 * threads));
queue = new LinkedBlockingDeque<Runnable>(500 * threads) {
private static final long serialVersionUID = 1L;
@Override
public boolean offer(Runnable r) {
Task task = (Task) r;
if (task.getFeed().isUrgent()) {
return offerFirst(r);
} else {
return offerLast(r);
}
}
});
pool.setRejectedExecutionHandler(new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {