org.semanticweb.elk.util.concurrent.computation
Class ComputationExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by org.semanticweb.elk.util.concurrent.computation.ComputationExecutor
All Implemented Interfaces:
Executor, ExecutorService

public class ComputationExecutor
extends ThreadPoolExecutor

A custom ExecutorService for starting a several copies of runnable tasks, and waiting for it computation; it allows to interrupt all running tasks without shutting down the ExecutorService. If terminated, the tasks can be started again.

Author:
"Yevgeny Kazakov"

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
ComputationExecutor(int threadCount, ComputationThreadGroup threadGroup)
          Create a ComputationExecutor with a given maximal number of threads and the given thread group
ComputationExecutor(int threadCount, String name)
          Create a ComputationExecutor with a given maximal number of threads and the the given name which is used to identify threads
 
Method Summary
 void interrupt()
          Interrupting all threads of this executor (used to wake up waiting threads if something needs to be notified)
 boolean start(Runnable job, int noCopies)
          Starts a several copies of jobs.
 void waitDone()
          Waits until all computations are done
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
afterExecute, allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComputationExecutor

public ComputationExecutor(int threadCount,
                           ComputationThreadGroup threadGroup)
Create a ComputationExecutor with a given maximal number of threads and the given thread group

Parameters:
threadCount -
threadGroup -

ComputationExecutor

public ComputationExecutor(int threadCount,
                           String name)
Create a ComputationExecutor with a given maximal number of threads and the the given name which is used to identify threads

Parameters:
threadCount -
name -
Method Detail

start

public boolean start(Runnable job,
                     int noCopies)
Starts a several copies of jobs. The jobs cannot be started again until the method waitDone() is called

Parameters:
job -
noCopies -
Returns:
true if the jobs have been started

interrupt

public void interrupt()
Interrupting all threads of this executor (used to wake up waiting threads if something needs to be notified)


waitDone

public void waitDone()
              throws InterruptedException
Waits until all computations are done

Throws:
InterruptedException - if was interrupted while waiting


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.