Last active
May 20, 2024 06:40
-
-
Save tokizuoh/e7bce4de01959ae88e31f382a70f1743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
Task.detached { | |
await self.heavyCall() | |
} | |
} | |
func heavyCall() async { | |
var count = 0 | |
while count < 1_000_000_000 { | |
count += 1 | |
await Task.yield() | |
} | |
print(Thread.isMainThread) // true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment