# Class: modelit.web.concurrent.ThreadPoolExecutor

### Extends: matlab.mixin.SetGet & handle

## DESCRIPTION:

Construct a pool with tasks to be executed by one or more threads. Tasks are taken from the pool depending on the number of threads. And are asynchronously executed. The tasks that can be added to the pool must be of type modelit.web.concurrent.Callable

#

## Properties

No properties

# Public Method: ThreadPoolExecutor

## DESCRIPTION:

Construct a pool with tasks to be executed by one or more threads. Tasks are taken from the pool depending on the number of threads. And are asynchronously executed. The tasks that can be added to the pool must be of type modelit.web.concurrent.Callable

## CALL:

obj = ThreadPoolExecutor(numberOfThreads)

## INPUT:

numberOfThreads | integer |
    Maximum number of threads for this pool, each thread
    executes one task.

## OUTPUT:

obj | modelit.web.concurrent.ThreadPoolExecutor |
      A pool with tasks, the executors asynchronously execute
      the tasks in this pool. The number of executors is given
      by the numberOfThreads argument.
    Documentation for modelit.web.concurrent.ThreadPoolExecutor/ThreadPoolExecutor
       doc modelit.web.concurrent.ThreadPoolExecutor

# Public Method: delete

## DESCRIPTION:

Stop the executor and remove the remaining tasks.

## CALL:

delete(obj)

## INPUT:

obj | modelit.web.concurrent.ThreadPoolExecutor |

## OUTPUT:

          No output, the ThreadPoolExecutor is shut down.

# Public Method: submit

## DESCRIPTION:

Add a new task to the pool. The ThreadPoolExecutor takes care of executing the tasks.

## CALL:

submit(obj, callable)

## INPUT:

obj | modelit.web.concurrent.ThreadPoolExecutor |
callable | modelit.web.concurrent.Callable |
    The task to be executed

## OUTPUT:

          No direct output, the task is added to the pool.
          The executor will execute the task when a thread is available.

# Public Method: getQueue

## DESCRIPTION:

Get the queue with remaining tasks.

## CALL:

queue = getQueue(obj)

## INPUT:

obj | modelit.web.concurrent.ThreadPoolExecutor |

## OUTPUT:

queue | integer |
    Number of tasks in the queue.

# Public Method: cancel

## DESCRIPTION:

Cancel the tasks that are in the pool but not executed.

## CALL:

cancel(obj)

## INPUT:

obj | modelit.web.concurrent.ThreadPoolExecutor |

## OUTPUT:

          Tasks that are in the pool but not yet executed are
          cancelled.