fixed a bug in PrioritizedThreadPoolExecutor:

now execute(Runnable) verifies the command is added as PrioritizedRunnable
This commit is contained in:
uboness 2013-02-09 03:26:52 +01:00
parent 6d9048f8cc
commit 678a8664f6
1 changed files with 8 additions and 0 deletions

View File

@ -47,6 +47,14 @@ public class PrioritizedEsThreadPoolExecutor extends EsThreadPoolExecutor {
super(corePoolSize, maximumPoolSize, keepAliveTime, unit, new PriorityBlockingQueue<Runnable>(initialWorkQueuSize), threadFactory, handler); super(corePoolSize, maximumPoolSize, keepAliveTime, unit, new PriorityBlockingQueue<Runnable>(initialWorkQueuSize), threadFactory, handler);
} }
@Override
public void execute(Runnable command) {
if (!(command instanceof PrioritizedRunnable)) {
command = PrioritizedRunnable.wrap(command, Priority.NORMAL);
}
super.execute(command);
}
@Override @Override
protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) { protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
if (!(runnable instanceof PrioritizedRunnable)) { if (!(runnable instanceof PrioritizedRunnable)) {