Skip to content

Commit

Permalink
TEIID-3099 preventing rejected execution with timing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Aug 25, 2014
1 parent a1f0fed commit 01e4533
Showing 1 changed file with 5 additions and 9 deletions.
Expand Up @@ -161,7 +161,7 @@ public ThreadReuseExecutor(String name, int maximumPoolSize) {
this.poolName = name;

tpe = new ThreadPoolExecutor(0,
maximumPoolSize, 2, TimeUnit.MINUTES,
Integer.MAX_VALUE, 2, TimeUnit.MINUTES,
new SynchronousQueue<Runnable>(), new NamedThreadFactory("Worker")) { //$NON-NLS-1$
@Override
protected void afterExecute(Runnable r, Throwable t) {
Expand All @@ -178,24 +178,20 @@ public void execute(final Runnable command) {
}

private void executeDirect(final PrioritizedRunnable command) {
boolean atMaxThreads = false;
synchronized (poolLock) {
checkForTermination();
submittedCount++;
atMaxThreads = activeCount == maximumPoolSize;
boolean atMaxThreads = activeCount == maximumPoolSize;
if (atMaxThreads) {
queue.add(command);
int queueSize = queue.size();
if (queueSize > highestQueueSize) {
highestQueueSize = queueSize;
}
} else {
activeCount++;
highestActiveCount = Math.max(activeCount, highestActiveCount);
return;
}
}
if (atMaxThreads) {
return;
activeCount++;
highestActiveCount = Math.max(activeCount, highestActiveCount);
}
tpe.execute(new Runnable() {
@Override
Expand Down

0 comments on commit 01e4533

Please sign in to comment.