Remove "isEmpty()" check as this may be really expensive (need to

traverse all elements in the queue)
This commit is contained in:
norman 2011-11-30 10:27:09 +01:00
parent 2686dc99b4
commit f6baf157df

View File

@ -311,8 +311,7 @@ public class OrderedMemoryAwareThreadPoolExecutor extends
Thread thread = Thread.currentThread();
for (;;) {
final Runnable task = tasks.poll();
// this should never happen but just in case check if
// the queue was empty
// if the task is null we should exit the loop
if (task == null) {
break;
}
@ -328,10 +327,6 @@ public class OrderedMemoryAwareThreadPoolExecutor extends
onAfterExecute(task, e);
}
throw e;
} finally {
if (tasks.isEmpty()) {
break;
}
}
}
} finally {