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