<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Thread/exit()",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSThread(cm)exit"
  },
  "title" : "exit()"
}
-->

# exit()

Terminates the current thread.

```
class func exit()
```

## Discussion

This method uses the [`current`](/documentation/Foundation/Thread/current) class method to access the current thread. Before exiting the thread, this method posts the [`NSThreadWillExit`](/documentation/Foundation/NSNotification/Name-swift.struct/NSThreadWillExit) with the thread being exited to the default notification center. Because notifications are delivered synchronously, all observers of [`NSThreadWillExit`](/documentation/Foundation/NSNotification/Name-swift.struct/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

[`current`](/documentation/Foundation/Thread/current)

Returns the thread object representing the current thread of execution.



---

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)