Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 20536 invoked from network); 13 Jan 2009 22:15:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jan 2009 22:15:49 -0000 Received: (qmail 74036 invoked by uid 500); 13 Jan 2009 22:15:49 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 74006 invoked by uid 500); 13 Jan 2009 22:15:49 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 73996 invoked by uid 99); 13 Jan 2009 22:15:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jan 2009 14:15:49 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jan 2009 22:15:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 45EED238887D; Tue, 13 Jan 2009 14:15:28 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r734256 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java Date: Tue, 13 Jan 2009 22:15:27 -0000 To: commits@activemq.apache.org From: gtully@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090113221528.45EED238887D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gtully Date: Tue Jan 13 14:15:25 2009 New Revision: 734256 URL: http://svn.apache.org/viewvc?rev=734256&view=rev Log: apply patch from https://issues.apache.org/activemq/browse/AMQ-2054 Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java?rev=734256&r1=734255&r2=734256&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/usage/Usage.java Tue Jan 13 14:15:25 2009 @@ -55,7 +55,7 @@ private List children = new CopyOnWriteArrayList(); private final List callbacks = new LinkedList(); private int pollingTime = 100; - private ThreadPoolExecutor executor; + private volatile ThreadPoolExecutor executor; private AtomicBoolean started=new AtomicBoolean(); public Usage(T parent, String name, float portion) { @@ -281,7 +281,7 @@ } @SuppressWarnings("unchecked") - public synchronized void start() { + public void start() { if (started.compareAndSet(false, true)){ if (parent != null) { parent.addChild(this); @@ -293,7 +293,7 @@ } @SuppressWarnings("unchecked") - public synchronized void stop() { + public void stop() { if (started.compareAndSet(true, false)){ if (parent != null) { parent.removeChild(this); @@ -400,19 +400,22 @@ this.parent = parent; } - protected synchronized Executor getExecutor() { + protected Executor getExecutor() { if (this.executor == null) { - this.executor = new ThreadPoolExecutor(1, 1, 0, - TimeUnit.NANOSECONDS, - new LinkedBlockingQueue(), new ThreadFactory() { - public Thread newThread(Runnable runnable) { - Thread thread = new Thread(runnable, getName() - + " Usage Thread Pool"); - thread.setDaemon(true); - return thread; - } - }); - + synchronized(usageMutex) { + if (this.executor == null) { + this.executor = new ThreadPoolExecutor(1, 1, 0, + TimeUnit.NANOSECONDS, + new LinkedBlockingQueue(), new ThreadFactory() { + public Thread newThread(Runnable runnable) { + Thread thread = new Thread(runnable, getName() + + " Usage Thread Pool"); + thread.setDaemon(true); + return thread; + } + }); + } + } } return this.executor; }