<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/TaskExecutor",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sch"
  },
  "title" : "TaskExecutor"
}
-->

# TaskExecutor

An executor that may be used as preferred executor by a task.

```
protocol TaskExecutor : Executor
```

## Overview

### Impact of setting a task executor preference

By default, without setting a task executor preference, nonisolated
asynchronous functions, as well as methods declared on default actors –
that is actors which do not require a specific executor – execute on
Swift’s default global concurrent executor. This is an executor shared by
the entire runtime to execute any work which does not have strict executor
requirements.

By setting a task executor preference, either with a
[`withTaskExecutorPreference(_:isolation:operation:)`](/documentation/Swift/withTaskExecutorPreference(_:isolation:operation:)) or creating a task
with a preference – using `Task(executorPreference:)` or
`group.addTask(executorPreference:)` – the task and all of its child tasks
(unless a new preference is set) will be preferring to execute on
the provided task executor.

Unstructured tasks do not inherit the task executor.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)