swift thread.sleep

Swift
while (true){
    print("sleep for 2 seconds.")
    sleep(2) // working
}

Source

Also in Swift: