---
title: exit()
framework: foundation
role: symbol
role_heading: Type Method
path: foundation/thread/exit()
---

# exit()

Terminates the current thread.

## Declaration

```swift
class func exit()
```

## Discussion

Discussion This method uses the current class method to access the current thread. Before exiting the thread, this method posts the NSThreadWillExit with the thread being exited to the default notification center. Because notifications are delivered synchronously, all observers of NSThreadWillExit are guaranteed to receive the notification before the thread exits. Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.

## See Also

### Related Documentation

- [current](foundation/thread/current.md)

### Stopping a Thread

- [sleep(until:)](foundation/thread/sleep(until:).md)
- [sleep(forTimeInterval:)](foundation/thread/sleep(fortimeinterval:).md)
- [cancel()](foundation/thread/cancel().md)
