com.asprise.ocr

## Class OcrExecutorService

- java.lang.Object
- - java.util.concurrent.AbstractExecutorService
  - - java.util.concurrent.ThreadPoolExecutor
    - - com.asprise.ocr.OcrExecutorService

- All Implemented Interfaces:
    Executor, ExecutorService

      public class OcrExecutorService
      extends ThreadPoolExecutor

  Executor service for OCR.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OcrExecutorService.OcrCallable` Represents an OCR task.

    - ### Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

      `ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ThreadLocal<Ocr>` | `threadLocalOcr`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OcrExecutorService(String lang, String speed)` A service executor with thread count equal to number of CPU core available.
    `OcrExecutorService(String lang, String speed, int poolSize)` Creates a new instance of OCR service executor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `getCpuCores()` Returns number of CPU core available for the current JVM.
    `void` | `shutdown()`
    `void` | `stopOcrEngines()`

    - ### Methods inherited from class java.util.concurrent.ThreadPoolExecutor

      `allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, execute, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdownNow, toString`

    - ### Methods inherited from class java.util.concurrent.AbstractExecutorService

      `invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### threadLocalOcr

          public static final ThreadLocal<Ocr> threadLocalOcr

  - ### Constructor Detail

    - #### OcrExecutorService

          public OcrExecutorService(String lang,
                            String speed)

      A service executor with thread count equal to number of CPU core available.
      Parameters:
        `lang` - language to recognize
        `speed` - speed settings, e.g., Ocr.SPEED_FASTEST.

    - #### OcrExecutorService

          public OcrExecutorService(String lang,
                            String speed,
                            int poolSize)

      Creates a new instance of OCR service executor
      Parameters:
        `lang` - language to recognize
        `speed` - speed settings, e.g., Ocr.SPEED_FASTEST.
        `poolSize` - number of threads to be used in this executor.

  - ### Method Detail

    - #### shutdown

          public void shutdown()

      Specified by:
        `shutdown` in interface `ExecutorService`
      Overrides:
        `shutdown` in class `ThreadPoolExecutor`

    - #### stopOcrEngines

          public void stopOcrEngines()

    - #### getCpuCores

          public static int getCpuCores()

      Returns number of CPU core available for the current JVM. If the CPU support hyper-threading, this number will be the double of the total cores.
      Returns:

Copyright © Asprise Software. All Rights Reserved. Please visit the product page at asprise.com