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

# sleep(for:tolerance:clock:)

Suspends the current task for the given duration.

## Declaration

```swift
static func sleep<C>(for duration: C.Instant.Duration, tolerance: C.Instant.Duration? = nil, clock: C = .continuous) async throws where C : Clock
```

## Discussion

Discussion If the task is canceled before the time ends, this function throws CancellationError. This function doesn’t block the underlying thread.   try await Task.sleep(for: .seconds(3))

## See Also

### Suspending Execution

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