// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.util.BlockingArrayQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.util.BlockingArrayQueue;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
private final AtomicInteger _threadsStarted = new AtomicInteger();
private final AtomicInteger _threadsIdle = new AtomicInteger();
private final AtomicLong _lastShrink = new AtomicLong();
private final AtomicInteger _threadsStarted = new AtomicInteger();
private final AtomicInteger _threadsIdle = new AtomicInteger();
private final AtomicLong _lastShrink = new AtomicLong();
private final Object _joinLock = new Object();
private final BlockingQueue<Runnable> _jobs;
private String _name = "qtp" + hashCode();
private final Object _joinLock = new Object();
private final BlockingQueue<Runnable> _jobs;
private String _name = "qtp" + hashCode();
- queue=new BlockingArrayQueue<>(_minThreads, _minThreads);
+ {
+ int capacity=Math.max(_minThreads, 8);
+ queue=new BlockingArrayQueue<>(capacity, capacity);
+ }
LOG.warn("{} rejected {}", this, job);
throw new RejectedExecutionException(job.toString());
}
LOG.warn("{} rejected {}", this, job);
throw new RejectedExecutionException(job.toString());
}
- out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(thread.getState().toString()).append(idle ? " IDLE" : "").append('\n');
+ out.append(String.valueOf(thread.getId())).append(' ').append(thread.getName()).append(' ').append(thread.getState().toString()).append(idle ? " IDLE" : "");
+ if (thread.getPriority()!=Thread.NORM_PRIORITY)
+ out.append(" prio=").append(String.valueOf(thread.getPriority()));
+ out.append(System.lineSeparator());
long now = System.nanoTime();
if (last == 0 || (now - last) > TimeUnit.MILLISECONDS.toNanos(_idleTimeout))
{
long now = System.nanoTime();
if (last == 0 || (now - last) > TimeUnit.MILLISECONDS.toNanos(_idleTimeout))
{
- shrink = _lastShrink.compareAndSet(last, now) &&
- _threadsStarted.compareAndSet(size, size - 1);
- if (shrink)
+ if (_lastShrink.compareAndSet(last, now) && _threadsStarted.compareAndSet(size, size - 1))
- if (!shrink)
- _threadsStarted.decrementAndGet();
+ if (!shrink && isRunning())
+ {
+ if (!ignore)
+ LOG.warn("Unexpected thread death: {} in {}",this,QueuedThreadPool.this);
+ // This is an unexpected thread death!
+ if (_threadsStarted.decrementAndGet()<getMaxThreads())
+ startThreads(1);
+ }