com.atlassian.jira.util.concurrent
Class BoundedExecutor

java.lang.Object
  extended by com.atlassian.jira.util.concurrent.BoundedExecutor
All Implemented Interfaces:
Executor

public class BoundedExecutor
extends Object
implements Executor

BoundedExecutor is an ExecutorService wrapper that bounds the number of runnables allowed in the execution queue. execute(Runnable) blocks if the number of runnables already in the queue equals the maximum number of permits available.


Constructor Summary
BoundedExecutor(ExecutorService executor, int permits)
          Constructor.
 
Method Summary
 void execute(Runnable command)
           
 void shutdownAndIgnoreQueue()
           
 void shutdownAndWait()
          shutdown the ExecutorService and wait for it.
<T> Future<T>
submit(Callable<T> task)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BoundedExecutor

public BoundedExecutor(ExecutorService executor,
                       int permits)
Constructor.

Parameters:
executor - the executor service whose queue is to be bounded (required)
permits - the number of runnables allowed in the queue at once
Method Detail

execute

public void execute(Runnable command)
Specified by:
execute in interface Executor

submit

public <T> Future<T> submit(Callable<T> task)

shutdownAndWait

public void shutdownAndWait()
shutdown the ExecutorService and wait for it. This method is not interruptible.


shutdownAndIgnoreQueue

public void shutdownAndIgnoreQueue()


Copyright © 2002-2014 Atlassian. All Rights Reserved.