Last active
May 19, 2024 03:40
-
-
Save tokizuoh/0c1c015d464d6f762728b3212c0b04a1 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 ViewModel { | |
func heavyCall() { | |
var count = 0 | |
while count < 1_000_000_000 { | |
count += 1 | |
} | |
print(Thread.isMainThread) // false | |
} | |
} | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
Task.detached { | |
let viewModel = ViewModel() | |
viewModel.heavyCall() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment