X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2Fconcurrent%2FFastThreadPoolExecutor.java;h=77a5846419e9db142c172d4dd30782a2827dbd37;hb=c55eefb2dcc799601c6ed51409cd5f670fb7fe73;hp=67b89aab516dc6b79f93e6d4356397db80636618;hpb=dd8b87bc7b7fc403735cd71fecc272d40ca9c673;p=yangtools.git diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/FastThreadPoolExecutor.java b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/FastThreadPoolExecutor.java index 67b89aab51..77a5846419 100644 --- a/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/FastThreadPoolExecutor.java +++ b/common/util/src/main/java/org/opendaylight/yangtools/util/concurrent/FastThreadPoolExecutor.java @@ -8,13 +8,12 @@ package org.opendaylight.yangtools.util.concurrent; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import com.google.common.base.Objects; -import com.google.common.base.Objects.ToStringHelper; -import com.google.common.util.concurrent.ThreadFactoryBuilder; - /** * A ThreadPoolExecutor with a specified bounded queue capacity that favors creating new threads * over queuing, as the former is faster. @@ -41,7 +40,7 @@ public class FastThreadPoolExecutor extends ThreadPoolExecutor { * @param threadPrefix * the name prefix for threads created by this executor. */ - public FastThreadPoolExecutor( int maximumPoolSize, int maximumQueueSize, String threadPrefix ) { + public FastThreadPoolExecutor( final int maximumPoolSize, final int maximumQueueSize, final String threadPrefix ) { this( maximumPoolSize, maximumQueueSize, DEFAULT_IDLE_TIMEOUT_IN_SEC, TimeUnit.SECONDS, threadPrefix ); } @@ -60,8 +59,8 @@ public class FastThreadPoolExecutor extends ThreadPoolExecutor { * @param threadPrefix * the name prefix for threads created by this executor. */ - public FastThreadPoolExecutor( int maximumPoolSize, int maximumQueueSize, long keepAliveTime, - TimeUnit unit, String threadPrefix ) { + public FastThreadPoolExecutor( final int maximumPoolSize, final int maximumQueueSize, final long keepAliveTime, + final TimeUnit unit, final String threadPrefix ) { // We use all core threads (the first 2 parameters below equal) so, when a task is submitted, // if the thread limit hasn't been reached, a new thread will be spawned to execute // the task even if there is an existing idle thread in the pool. This is faster than @@ -77,7 +76,7 @@ public class FastThreadPoolExecutor extends ThreadPoolExecutor { setThreadFactory( new ThreadFactoryBuilder().setDaemon( true ) .setNameFormat( threadPrefix + "-%d" ).build() ); - if( keepAliveTime > 0 ) { + if (keepAliveTime > 0) { // Need to specifically configure core threads to timeout. allowCoreThreadTimeOut( true ); } @@ -89,13 +88,13 @@ public class FastThreadPoolExecutor extends ThreadPoolExecutor { return ((TrackingLinkedBlockingQueue)getQueue()).getLargestQueueSize(); } - protected ToStringHelper addToStringAttributes( ToStringHelper toStringHelper ) { + protected ToStringHelper addToStringAttributes( final ToStringHelper toStringHelper ) { return toStringHelper; } @Override public final String toString() { - return addToStringAttributes( Objects.toStringHelper( this ) + return addToStringAttributes( MoreObjects.toStringHelper( this ) .add( "Thread Prefix", threadPrefix ) .add( "Current Thread Pool Size", getPoolSize() ) .add( "Largest Thread Pool Size", getLargestPoolSize() )