<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/Task/immediate(name:priority:executorPreference:operation:)-88o80",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ScT12_Concurrencys5NeverORs_rlE9immediate4name8priority18executorPreference9operationScTyxACGSSSg_ScPSgSch_pSgnxyYaYAcntFZ"
  },
  "title" : "immediate(name:priority:executorPreference:operation:)"
}
-->

# immediate(name:priority:executorPreference:operation:)

Create and immediately start running a new task in the context of the calling thread/task.

```
@discardableResult static func immediate(name: String? = nil, priority: TaskPriority? = nil, executorPreference taskExecutor: consuming (any TaskExecutor)? = nil, operation: sending @escaping @isolated(any) () async -> Success) -> Task<Success, Never>
```

## Parameters

`name`

The high-level human-readable name given for this task

`priority`

The priority of the task.
Pass `nil` to use the [`basePriority`](/documentation/Swift/Task/basePriority) of the current task (if there is one).

`taskExecutor`

The task executor that the child task should be started on and keep using.
Explicitly passing `nil` as the executor preference is equivalent to no preference,
and effectively means to inherit the outer context’s executor preference.
You can also pass the [`globalConcurrentExecutor`](/documentation/Swift/globalConcurrentExecutor) global executor explicitly.

`operation`

the operation to be run immediately upon entering the task.

## Return Value

A reference to the unstructured task which may be awaited on.

## Discussion

This function *starts* the created task on the calling context.
The task will continue executing on the caller’s context until it suspends,
and after suspension will resume on the adequate executor. For a nonisolated
operation this means running on the global concurrent pool, and on an isolated
operation it means the appropriate executor of that isolation context.

As indicated by the lack of `async` on this method, this method does *not*
suspend, and instead takes over the calling task’s (thread’s) execution in
a synchronous manner.

Other than the execution semantics discussed above, the created task
is semantically equivalent to a task created using
the `Task/init(name:priority:operation:)` initializer.

---

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)