Skip to content

Instantly share code, notes, and snippets.

@tokizuoh
Created March 31, 2024 08:19
Show Gist options
  • Save tokizuoh/71823002e4a2bda9cd9d6871e53033d6 to your computer and use it in GitHub Desktop.
Save tokizuoh/71823002e4a2bda9cd9d6871e53033d6 to your computer and use it in GitHub Desktop.
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Task.init {
try await sleep() // 何秒かかる?
}
}
func sleep() async throws {
async let a = Task.sleep(nanoseconds: 2_000_000_000)
async let b = Task.sleep(nanoseconds: 5_000_000_000)
print(try await a, try await b)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment