<!--
{
  "documentType" : "article",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/concurrency",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Concurrency"
}
-->

# Concurrency

Perform asynchronous and parallel operations.

## Topics

### Essentials

  <doc://com.apple.Swift/documentation/Swift/code-along-elevating-an-app-with-swift-concurrency>

  <doc://com.apple.Swift/documentation/Swift/updating-an-app-to-use-strict-concurrency>

  <doc://com.apple.Swift/documentation/Swift/updating-an-app-to-use-swift-concurrency>

### Tasks

[`struct Task`](/documentation/Swift/Task)

A unit of asynchronous work.

[`struct TaskGroup`](/documentation/Swift/TaskGroup)

A group that contains dynamically created child tasks.

[`func withTaskGroup<ChildTaskResult, GroupResult>(of: ChildTaskResult.Type, returning: GroupResult.Type, isolation: isolated (any Actor)?, body: (inout TaskGroup<ChildTaskResult>) async -> GroupResult) async -> GroupResult`](/documentation/Swift/withTaskGroup(of:returning:isolation:body:))

Starts a new scope that can contain a dynamic number of child tasks.

[`struct ThrowingTaskGroup`](/documentation/Swift/ThrowingTaskGroup)

A group that contains throwing, dynamically created child tasks.

[`func withThrowingTaskGroup<ChildTaskResult, GroupResult>(of: ChildTaskResult.Type, returning: GroupResult.Type, isolation: isolated (any Actor)?, body: (inout ThrowingTaskGroup<ChildTaskResult, any Error>) async throws -> GroupResult) async rethrows -> GroupResult`](/documentation/Swift/withThrowingTaskGroup(of:returning:isolation:body:))

Starts a new scope that can contain a dynamic number of throwing child tasks.

[`struct TaskPriority`](/documentation/Swift/TaskPriority)

The priority of a task.

[`struct DiscardingTaskGroup`](/documentation/Swift/DiscardingTaskGroup)

A discarding group that contains dynamically created child tasks.

[`func withDiscardingTaskGroup<GroupResult>(returning: GroupResult.Type, isolation: isolated (any Actor)?, body: (inout DiscardingTaskGroup) async -> GroupResult) async -> GroupResult`](/documentation/Swift/withDiscardingTaskGroup(returning:isolation:body:))

Starts a new scope that can contain a dynamic number of child tasks.

[`struct ThrowingDiscardingTaskGroup`](/documentation/Swift/ThrowingDiscardingTaskGroup)

A throwing discarding group that contains dynamically created child tasks.

[`func withThrowingDiscardingTaskGroup<GroupResult>(returning: GroupResult.Type, isolation: isolated (any Actor)?, body: (inout ThrowingDiscardingTaskGroup<any Error>) async throws -> GroupResult) async throws -> GroupResult`](/documentation/Swift/withThrowingDiscardingTaskGroup(returning:isolation:body:))

Starts a new scope that can contain a dynamic number of child tasks.

[`struct UnsafeCurrentTask`](/documentation/Swift/UnsafeCurrentTask)

An unsafe reference to the current task.

### Asynchronous Sequences

[`protocol AsyncSequence`](/documentation/Swift/AsyncSequence)

A type that provides asynchronous, sequential, iterated access to its
elements.

[`struct AsyncStream`](/documentation/Swift/AsyncStream)

An asynchronous sequence generated from a closure that calls a continuation
to produce new elements.

[`struct AsyncThrowingStream`](/documentation/Swift/AsyncThrowingStream)

An asynchronous sequence generated from an error-throwing closure that
calls a continuation to produce new elements.

### Continuations

[`struct Continuation`](/documentation/Swift/Continuation)

A mechanism to interface between synchronous and asynchronous code,
which enforces that the continuation is resumed exactly once.

[`func withContinuation<Success>(of: Success.Type, (consuming Continuation<Success, Never>) -> Void) async -> sending Success`](/documentation/Swift/withContinuation(of:_:))

Invokes the passed in closure with a non-copyable continuation for the current task.

[`func withContinuation<Success, Failure>(of: Success.Type, throwing: Failure.Type, (consuming Continuation<Success, Failure>) -> Void) async throws(Failure) -> sending Success`](/documentation/Swift/withContinuation(of:throwing:_:))

Invokes the passed in closure with a non-copyable continuation for the current task.

[`struct CheckedContinuation`](/documentation/Swift/CheckedContinuation)

A mechanism to interface
between synchronous and asynchronous code,
logging correctness violations.

[`func withCheckedContinuation<T>(function: String, (CheckedContinuation<T, Never>) -> Void) async -> sending T`](/documentation/Swift/withCheckedContinuation(function:_:))

Invokes the passed in closure with a checked continuation for the current task.

[`func withCheckedThrowingContinuation<T>(function: String, (CheckedContinuation<T, any Error>) -> Void) async throws -> sending T`](/documentation/Swift/withCheckedThrowingContinuation(function:_:)-13yf6)

[`func withCheckedThrowingContinuation<T, E>(function: String, (CheckedContinuation<T, E>) -> Void) async throws(E) -> sending T`](/documentation/Swift/withCheckedThrowingContinuation(function:_:)-2k46m)

Invokes the passed in closure with a checked continuation for the current task.

[`struct UnsafeContinuation`](/documentation/Swift/UnsafeContinuation)

A mechanism to interface
between synchronous and asynchronous code,
without correctness checking.

[`func withUnsafeContinuation<T>((UnsafeContinuation<T, Never>) -> Void) async -> sending T`](/documentation/Swift/withUnsafeContinuation(_:))

Invokes the passed in closure with a unsafe continuation for the current task.

### Actors

[`protocol Sendable`](/documentation/Swift/Sendable)

A thread-safe type whose values can be shared across arbitrary concurrent
contexts without introducing a risk of data races.

[`protocol Actor`](/documentation/Swift/Actor)

Common protocol to which all actors conform.

[`actor MainActor`](/documentation/Swift/MainActor)

A singleton actor whose executor is equivalent to the main
dispatch queue.

[`protocol GlobalActor`](/documentation/Swift/GlobalActor)

A type that represents a globally-unique actor that can be used to isolate
various declarations anywhere in the program.

[`protocol SendableMetatype`](/documentation/Swift/SendableMetatype)

A type whose metatype can be shared across arbitrary isolation domains
without introducing a risk of data races.

[`macro isolation<T>() -> T`](/documentation/Swift/isolation())

Produce a reference to the actor to which the enclosing code is
isolated, or `nil` if the code is nonisolated.

### Task-Local Storage

[`class TaskLocal`](/documentation/Swift/TaskLocal)

Wrapper type that defines a task-local value key.

[`macro TaskLocal()`](/documentation/Swift/TaskLocal())

Macro that introduces a [`TaskLocal`](/documentation/Swift/TaskLocal) binding.

### Executors

[`protocol Executor`](/documentation/Swift/Executor)

A service that can execute jobs.

[`struct ExecutorJob`](/documentation/Swift/ExecutorJob)

A unit of schedulable work.

[`protocol SerialExecutor`](/documentation/Swift/SerialExecutor)

A service that executes jobs.

[`protocol TaskExecutor`](/documentation/Swift/TaskExecutor)

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

[`struct UnownedJob`](/documentation/Swift/UnownedJob)

A unit of schedulable work.

[`struct JobPriority`](/documentation/Swift/JobPriority)

The priority of this job.

[`struct UnownedSerialExecutor`](/documentation/Swift/UnownedSerialExecutor)

An unowned reference to a serial executor (a `SerialExecutor`
value).

[`struct UnownedTaskExecutor`](/documentation/Swift/UnownedTaskExecutor)

[`var globalConcurrentExecutor: any TaskExecutor`](/documentation/Swift/globalConcurrentExecutor)

The global concurrent executor that is used by default for Swift Concurrency
tasks.

[`func withTaskExecutorPreference<T, Failure>((any TaskExecutor)?, isolation: isolated (any Actor)?, operation: () async throws(Failure) -> T) async throws(Failure) -> T`](/documentation/Swift/withTaskExecutorPreference(_:isolation:operation:))

Configure the current task hierarchy’s task executor preference to the passed [`TaskExecutor`](/documentation/Swift/TaskExecutor),
and execute the passed in closure by immediately hopping to that executor.

### Main and Task Executors

### Deprecated

[`func extractIsolation<each Arg, Result>((repeat each Arg) async throws -> Result) -> (any Actor)?`](/documentation/Swift/extractIsolation(_:))

[`func withCheckedContinuation<T>(isolation: isolated (any Actor)?, function: String, (CheckedContinuation<T, Never>) -> Void) async -> sending T`](/documentation/Swift/withCheckedContinuation(isolation:function:_:))

Source-compatibility overload; replaced by
[`withCheckedContinuation(function:_:)`](/documentation/Swift/withCheckedContinuation(function:_:)).

[`func withCheckedThrowingContinuation<T>(isolation: isolated (any Actor)?, function: String, (CheckedContinuation<T, any Error>) -> Void) async throws -> sending T`](/documentation/Swift/withCheckedThrowingContinuation(isolation:function:_:))

Source-compatibility overload; replaced by
[`withCheckedThrowingContinuation(function:_:)`](/documentation/Swift/withCheckedThrowingContinuation(function:_:)-2k46m).

[`func withUnsafeContinuation<T>(isolation: isolated (any Actor)?, (UnsafeContinuation<T, Never>) -> Void) async -> sending T`](/documentation/Swift/withUnsafeContinuation(isolation:_:))

Source-compatibility overload; replaced by
[`withUnsafeContinuation(_:)`](/documentation/Swift/withUnsafeContinuation(_:)).

[`typealias AnyActor`](/documentation/Swift/AnyActor)

Common marker protocol providing a shared “base” for both (local) `Actor`
and (potentially remote) `DistributedActor` types.

[`typealias ConcurrentValue`](/documentation/Swift/ConcurrentValue)

[`struct Job`](/documentation/Swift/Job)

Deprecated equivalent of [`ExecutorJob`](/documentation/Swift/ExecutorJob).

[`typealias PartialAsyncTask`](/documentation/Swift/PartialAsyncTask)

[`typealias UnsafeConcurrentValue`](/documentation/Swift/UnsafeConcurrentValue)

[`protocol UnsafeSendable`](/documentation/Swift/UnsafeSendable)

A type whose values can safely be passed across concurrency domains by copying,
but which disables some safety checking at the conformance site.

[`typealias UnsafeThrowingContinuation`](/documentation/Swift/UnsafeThrowingContinuation)

[`func withUnsafeThrowingContinuation<T, E>((UnsafeContinuation<T, E>) -> Void) async throws(E) -> sending T`](/documentation/Swift/withUnsafeThrowingContinuation(_:)-32nwt)

Invokes the passed in closure with a unsafe continuation for the current task.

[`func withUnsafeThrowingContinuation<T>((UnsafeContinuation<T, any Error>) -> Void) async throws -> sending T`](/documentation/Swift/withUnsafeThrowingContinuation(_:)-7zhvy)

[`func withUnsafeThrowingContinuation<T>(isolation: isolated (any Actor)?, (UnsafeContinuation<T, any Error>) -> Void) async throws -> sending T`](/documentation/Swift/withUnsafeThrowingContinuation(isolation:_:))

Source-compatibility overload; replaced by
[`withUnsafeThrowingContinuation(_:)`](/documentation/Swift/withUnsafeThrowingContinuation(_:)-32nwt).



---

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)