---
title: yield()
framework: swift
role: symbol
role_heading: Type Method
path: swift/task/yield()
---

# yield()

Suspends the current task and allows other tasks to execute.

## Declaration

```swift
static func yield() async
```

## Discussion

Discussion A task can voluntarily suspend itself in the middle of a long-running operation that doesn’t contain any suspension points, to let other tasks run for a while before execution returns to this task. If this task is the highest-priority task in the system, the executor immediately resumes execution of the same task. As such, this method isn’t necessarily a way to avoid resource starvation.

## See Also

### Suspending Execution

- [sleep(nanoseconds:)](swift/task/sleep(nanoseconds:).md)
- [sleep(for:tolerance:clock:)](swift/task/sleep(for:tolerance:clock:).md)
- [sleep(until:tolerance:clock:)](swift/task/sleep(until:tolerance:clock:).md)
