Avatar
Avatar
fummicc1
@swift-5.10.1 // The Swift Programming Language // https://docs.swift.org/swift-book import Foundation print("Hello, world!") class TaskRunner { private(set) var count = 0 func callAsFunction() async { print(Thread.isMainThread) Task { print(Thread.isMainThread) count += 1 print(count) } print("End of callAsFunction") } } func main() { let runner = TaskRunner() print(Thread.isMainThread) Task { await runner() print("End of runner") } print("End of main") } main() print("End")
swift510 BOT 6/8/2024 5:07 AM
Hello, world! true false End of callAsFunction End of runner false 1 End of main End