# Interface StructuredTaskScope.Configuration

Enclosing interface:
  `StructuredTaskScopePREVIEW<T,R>`

public static sealed interface StructuredTaskScope.Configuration
`Configuration` is a preview API of the Java platform.
Programs can only use `Configuration` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Represents the configuration for a `StructuredTaskScope`.

The configuration for a `StructuredTaskScope` consists of a `ThreadFactory` to create threads, an optional name for the purposes of monitoring and management, and an optional timeout.

Creating a `StructuredTaskScope` with `StructuredTaskScope.open()`PREVIEW or `StructuredTaskScope.open(Joiner)`PREVIEW uses the default configuration. The default configuration consists of a thread factory that creates unnamed virtual threads, no name for monitoring and management purposes, and no timeout.

Creating a `StructuredTaskScope` with its 2-arg `open`PREVIEW method allows a different configuration to be used. The function specified to the `open` method is applied to the default configuration and returns the configuration for the `StructuredTaskScope` under construction. The function can use the `with-` prefixed methods defined here to specify the components of the configuration to use.

Unless otherwise specified, passing a `null` argument to a method in this class will cause a `NullPointerException` to be thrown.

Since:
  25

- ## Method Summary

  Modifier and Type
  Method
  Description
  `StructuredTaskScope.ConfigurationPREVIEW`
  `withName(String name)`
  Returns a new `Configuration` object with the given name.
  `StructuredTaskScope.ConfigurationPREVIEW`
  `withThreadFactory(ThreadFactory threadFactory)`
  Returns a new `Configuration` object with the given thread factory.
  `StructuredTaskScope.ConfigurationPREVIEW`
  `withTimeout(Duration timeout)`
  Returns a new `Configuration` object with the given timeout.

- ## Method Details

  - ### withThreadFactory

    StructuredTaskScope.ConfigurationPREVIEW withThreadFactory(ThreadFactory threadFactory)
    Returns a new `Configuration` object with the given thread factory. The other components are the same as this object. The thread factory is used by a scope to create threads when forkingPREVIEW subtasks.
    Parameters:
      `threadFactory` - the thread factory
    Returns:
      a new `Configuration` object with the given thread factory
    See Also:
      - `StructuredTaskScope.fork(Callable)`PREVIEW
    API Note:
      The thread factory will typically create virtual threads, maybe with names for monitoring purposes, an uncaught exception handler, or other properties configured.

  - ### withName

    StructuredTaskScope.ConfigurationPREVIEW withName(String name)
    Returns a new `Configuration` object with the given name. The other components are the same as this object. A scope is optionally named for the purposes of monitoring and management.
    Parameters:
      `name` - the name
    Returns:
      a new `Configuration` object with the given name

  - ### withTimeout

    StructuredTaskScope.ConfigurationPREVIEW withTimeout(Duration timeout)
    Returns a new `Configuration` object with the given timeout. The other components are the same as this object.
    Parameters:
      `timeout` - the timeout
    Returns:
      a new `Configuration` object with the given timeout
    See Also:
      - `StructuredTaskScope.join()`PREVIEW
    API Note:
      Applications using deadlines, expressed as an `Instant`, can use `Duration.between(Instant.now(), deadline)` to compute the timeout for this method.