mirror of https://github.com/apache/activemq.git
apply patch from https://issues.apache.org/activemq/browse/AMQ-2054
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@734256 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b5b6a0834d
commit
20006a030d
|
@ -55,7 +55,7 @@ public abstract class Usage<T extends Usage> implements Service {
|
||||||
private List<T> children = new CopyOnWriteArrayList<T>();
|
private List<T> children = new CopyOnWriteArrayList<T>();
|
||||||
private final List<Runnable> callbacks = new LinkedList<Runnable>();
|
private final List<Runnable> callbacks = new LinkedList<Runnable>();
|
||||||
private int pollingTime = 100;
|
private int pollingTime = 100;
|
||||||
private ThreadPoolExecutor executor;
|
private volatile ThreadPoolExecutor executor;
|
||||||
private AtomicBoolean started=new AtomicBoolean();
|
private AtomicBoolean started=new AtomicBoolean();
|
||||||
|
|
||||||
public Usage(T parent, String name, float portion) {
|
public Usage(T parent, String name, float portion) {
|
||||||
|
@ -281,7 +281,7 @@ public abstract class Usage<T extends Usage> implements Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public synchronized void start() {
|
public void start() {
|
||||||
if (started.compareAndSet(false, true)){
|
if (started.compareAndSet(false, true)){
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.addChild(this);
|
parent.addChild(this);
|
||||||
|
@ -293,7 +293,7 @@ public abstract class Usage<T extends Usage> implements Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public synchronized void stop() {
|
public void stop() {
|
||||||
if (started.compareAndSet(true, false)){
|
if (started.compareAndSet(true, false)){
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parent.removeChild(this);
|
parent.removeChild(this);
|
||||||
|
@ -400,19 +400,22 @@ public abstract class Usage<T extends Usage> implements Service {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized Executor getExecutor() {
|
protected Executor getExecutor() {
|
||||||
if (this.executor == null) {
|
if (this.executor == null) {
|
||||||
this.executor = new ThreadPoolExecutor(1, 1, 0,
|
synchronized(usageMutex) {
|
||||||
TimeUnit.NANOSECONDS,
|
if (this.executor == null) {
|
||||||
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
|
this.executor = new ThreadPoolExecutor(1, 1, 0,
|
||||||
public Thread newThread(Runnable runnable) {
|
TimeUnit.NANOSECONDS,
|
||||||
Thread thread = new Thread(runnable, getName()
|
new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
|
||||||
+ " Usage Thread Pool");
|
public Thread newThread(Runnable runnable) {
|
||||||
thread.setDaemon(true);
|
Thread thread = new Thread(runnable, getName()
|
||||||
return thread;
|
+ " Usage Thread Pool");
|
||||||
}
|
thread.setDaemon(true);
|
||||||
});
|
return thread;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this.executor;
|
return this.executor;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue