import Foundation @MainActor func main() async { print(Thread.current.isMainThread) async let x = { print("foo", Thread.current.isMainThread) // 重めの同期処理 return 42 }() print("bar") print(await x) } await main()
true bar foo false 42
(edited)