- You should have basic knowledge of Kotlin. While all the concepts, primitives, and code related to concurrency are explained in great detail, some basic knowledge is assumed. For example, you should know how to create variables, classes, what a lambda is, and such like.
- No knowledge of concurrency is assumed. This book aims to give you an introduction to concurrency, plus how to approach it from a pure Kotlin perspective.
- Read the code samples with attention to detail, and ensure that you follow along the creation of the Android application. It will be easier for you to learn if you really dedicate the time to putting things in practice.
- An installation of IntelliJ IDEA Community 18.01 or a more recent version is expected. We will cover the installation of Android Studio 3.1 during Chapter 2, Coroutines in Action, so that you can follow the development of the RSS reader.
To get the most out of this book
Download the example code files
You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
- Log in or register at www.packtpub.com.
- Select the SUPPORT tab.
- Click on Code Downloads & Errata.
- Enter the name of the book in the Search box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
- WinRAR/7-Zip for Windows
- Zipeg/iZip/UnRarX for Mac
- 7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-Concurrency-in-Kotlin. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
CodeInText: Indicates the name of variables, functions, classes, packages, files, and URLs. Here is an example: "The hcf() function will freeze the system."
A block of code is set as follows:
fun main(args: Array<String>) = runBlocking {
val time = measureTimeMillis {
val name = async { getName() }
val lastName = async { getLastName() }
println("Hello, ${name.await()} ${lastName.await()}")
}
println("Execution took $time ms")
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
fun main(args: Array<String>) = runBlocking {
val netDispatcher = newSingleThreadContext(name = "ServiceCall")
val task = launch(netDispatcher) {
printCurrentThread()
}
task.join()
}
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Please make sure that the Include Kotlin Support option is enabled."