org.encog.util.concurrency

## Class EngineConcurrency

- java.lang.Object
- - org.encog.util.concurrency.EngineConcurrency

- All Implemented Interfaces:
    MultiThreadable

      public class EngineConcurrency
      extends Object
      implements MultiThreadable

  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

    Constructors
    Constructor and Description
    `EngineConcurrency()` Construct a concurrency object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `checkError()` Check to see if one of the threads has thrown an error.
    `TaskGroup` | `createTaskGroup()` Create a new task group.
    `static EngineConcurrency` | `getInstance()`
    `int` | `getThreadCount()`
    `void` | `processTask(EngineTask task)` Process the specified task.
    `void` | `processTask(EngineTask task, TaskGroup group)` Process the specified task.
    `void` | `registerError(Throwable t)` Allows threads to register errors, these errors will be thrown by the main thread.
    `void` | `setThreadCount(int t)` Set the number of threads to use.
    `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

    - #### EngineConcurrency

          public EngineConcurrency()

      Construct a concurrency object.

  - ### Method Detail

    - #### getInstance

          public static EngineConcurrency getInstance()

      Returns:
        The instance to the singleton.

    - #### setThreadCount

          public void setThreadCount(int t)

      Set the number of threads to use.
      Specified by:
        `setThreadCount` in interface `MultiThreadable`
      Parameters:
        `t` - The number of threads to use, or zero to automatically determine based on core count.

    - #### checkError

          public void checkError()

      Check to see if one of the threads has thrown an error. If so, then throw that error.

    - #### createTaskGroup

          public TaskGroup createTaskGroup()

      Create a new task group.
      Returns:
        The new task group.

    - #### processTask

          public void processTask(EngineTask task)

      Process the specified task.
      Parameters:
        `task` - The task to process.

    - #### processTask

          public void processTask(EngineTask task,
                         TaskGroup group)

      Process the specified task. It will be processed either now, or queued to process on the thread pool.
      Parameters:
        `task` - The task to process.
        `group` - The task group.

    - #### registerError

          public void registerError(Throwable t)

      Allows threads to register errors, these errors will be thrown by the main thread.
      Parameters:
        `t` - The error to register.

    - #### 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.

    - #### getThreadCount

          public int getThreadCount()

      Specified by:
        `getThreadCount` in interface `MultiThreadable`
      Returns:
        The number of threads to use, 0 to automatically determine based on core count.

Copyright © 2014. All Rights Reserved.