O'Reilly logo

Swift High Performance by Kostiantyn Koval

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Concurrency overview

By default, when you make an application it runs the code in a single-thread environment, a main thread. For example, an iOS application would call the application: didFinishLaunchingWithOptions method on the main thread.

A simpler example is an OS X Command Line Tool application. It has only one file: main.swift. When you start it, the system creates a single main thread and runs all the code in the main.swift file on that thread.

For testing code, playgrounds are the best. By default, playgrounds stop after executing the last line of code and don't wait for the concurrent code to finish executing. We can change this behavior by telling the playgrounds to keep running indefinitely. To do that, include these two lines in the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required