---
title: ScheduledExecutorService
description: An executor service to schedule tasks for execution after a delay or for repeated execution with a fixed interval of time in between each execution. You can configure the number of threads in the executor service and how the executor service is stopped.
component: pinggateway
version: 2026
page_id: pinggateway:reference:ScheduledExecutorService
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/ScheduledExecutorService.html
revdate: 2025-06-02T18:01:47Z
section_ids:
  ScheduledExecutorService-usage: Usage
  ScheduledExecutorService-properties: Properties
  ScheduledExecutorService-example: Example
  ScheduledExecutorService-moreinfo: More information
---

# ScheduledExecutorService

An executor service to schedule tasks for execution after a delay or for repeated execution with a fixed interval of time in between each execution. You can configure the number of threads in the executor service and how the executor service is stopped.

The `ScheduledExecutorService` is shared by all downstream components that use an executor service.

## Usage

```json
{
  "name": string,
  "type": "ScheduledExecutorService",
  "config": {
    "corePoolSize": configuration expression<number>,
    "gracefulStop": configuration expression<boolean>,
    "gracePeriod": configuration expression<duration>
  }
}
```

## Properties

* `"corePoolSize"`: *configuration expression<[number](preface.html#definition-number)>, optional*

  The minimum number of threads to keep in the pool. If this property is an expression, the expression is evaluated as soon as the configuration is read.

  The value must be an integer greater than zero.

  Default: 1

* `"gracefulStop"`: *configuration expression<[boolean](preface.html#definition-boolean)>, optional*

  Defines how the executor service stops.

  If true, the executor service does the following:

  * Blocks the submission of new jobs.

  * If a grace period is defined, waits for up to that maximum time for submitted and running jobs to finish.

  * Removes submitted jobs without running them.

  * Attempts to end running jobs.

    If false, the executor service does the following:

  * Blocks the submission of new jobs.

  * If a grace period is defined, ignores it.

  * Removes submitted jobs without running them.

  * Attempts to end running jobs.

  Default: true

* `"gracePeriod"`: *configuration expression<[duration](preface.html#definition-duration)>, optional*

  The maximum time that the executor service waits for running jobs to finish before it stops. If this property is an expression, the expression is evaluated as soon as the configuration is read.

  If all jobs finish before the grace period, the executor service stops without waiting any longer. If jobs are still running after the grace period, the executor service removes the scheduled tasks, and notifies the running tasks for interruption.

  When `gracefulStop` is `false`, the grace period is ignored.

  Default: 10 seconds

## Example

The following example creates a thread pool to execute tasks. When the executor service is instructed to stop, it blocks the submission of new jobs, and waits for up to 10 seconds for submitted and running jobs to complete before it stops. If any jobs are still submitted or running after 10 seconds, the executor service stops anyway and prints a message.

```json
{
    "name": "ExecutorService",
    "comment": "Default service for executing tasks in the background.",
    "type": "ScheduledExecutorService",
    "config": {
        "corePoolSize": 5,
        "gracefulStop": true,
        "gracePeriod": "10 seconds"
    }
}
```

## More information

[org.forgerock.openig.thread.ScheduledExecutorServiceHeaplet](../_attachments/apidocs/org/forgerock/openig/thread/ScheduledExecutorServiceHeaplet.html)
