The Encog Project

org.encog.util.concurrency
Class EncogConcurrency

java.lang.Object
  extended by org.encog.util.concurrency.EncogConcurrency

public class EncogConcurrency
extends java.lang.Object

This class abstracts thread pools, and potentially grids and other types of concurrency. It is used by other classes inside of Encog to allow tasks to be executed efficiently on multicore machines.

Author:
jheaton

Constructor Summary
EncogConcurrency()
          Construct a concurrency object.
 
Method Summary
static EncogConcurrency getInstance()
           
 void processTask(EncogTask task)
          Process the specified task.
 void setMaxThreads(int maxThreads)
          Set the maximum number of threads to use.
 void setMaxThreadsToCoreCount()
          Set the max threads to the number of processors.
 void shutdown(long timeout)
          Wait for all threads in the pool to complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncogConcurrency

public EncogConcurrency()
Construct a concurrency object.

Method Detail

getInstance

public static EncogConcurrency getInstance()
Returns:
The instance to the singleton.

processTask

public void processTask(EncogTask task)
Process the specified task. It will be processed either now, or queued to process on the thread pool.

Parameters:
task - The task to process.

setMaxThreads

public void setMaxThreads(int maxThreads)
Set the maximum number of threads to use.

Parameters:
maxThreads - Maximum number of threads to use.

setMaxThreadsToCoreCount

public void setMaxThreadsToCoreCount()
Set the max threads to the number of processors.


shutdown

public void shutdown(long timeout)
Wait for all threads in the pool to complete.

Parameters:
timeout - How long to wait for all threads to complete.

The Encog Project