Skip to content

Instantly share code, notes, and snippets.

@tokizuoh
Created May 19, 2024 03:37
Show Gist options
  • Save tokizuoh/d1384eea5ef0d51ca07228c24ec6fd23 to your computer and use it in GitHub Desktop.
Save tokizuoh/d1384eea5ef0d51ca07228c24ec6fd23 to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Task.detached {
self.heavyCall()
}
}
nonisolated func heavyCall() {
var count = 0
while count < 1_000_000_000 {
count += 1
}
print(Thread.isMainThread) // false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment