---
title: "sleep(nanoseconds:)"
framework: swift
role: symbol
role_heading: Type Method
path: "swift/task/sleep(nanoseconds:)"
---

# sleep(nanoseconds:)

Suspends the current task for at least the given duration in nanoseconds.

## Declaration

```swift
static func sleep(nanoseconds duration: UInt64) async throws
```

## Discussion

Discussion If the task is canceled before the time ends, this function throws CancellationError. This function doesn’t block the underlying thread.

## See Also

### Suspending Execution

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