Skip to content

Latest commit

 

History

History

concurrency-in-kotlin

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Book – Concurrency in Kotlin

Kotlin project Directory concurrency-in-kotlin\ contains Kotlin code examples coming from the Learn Concurrency in Kotlin book 1.
It also includes several build scripts for experimenting with Kotlin on a Windows machine.

Code examples can be built/run with the following tools:

Build tool Build file Parent file Environment(s)
gradle.bat build.gradle Any a)
mvn.cmd pom.xml pom.xml Any
cmd.exe build.bat
a) Here "Any" means "tested on Windows / Cygwin / MSYS2 / Unix".
 

Coroutine Example

The code source consists of file Main.kt. This example has the following directory structure :

> tree /f /a . | findstr /v /b [A-Z]
|   build.bat
|   build.gradle
|   gradle.properties
|   pom.xml
\---src
    \---main
        \---kotlin
                Main.kt

Command [gradle]clean run generates and executes the Kotlin program `target.

> gradle clean run
1 threads active at the start
Started 1 in main
Started 2 in main
...
Started 9999 in main
Started 10000 in main
Finished 1 in main
Finished 2 in main
...
Finished 9999 in main
Finished 10000 in main
1 threads active at the end
Took 1450 ms

Concurrent Example

> gradle clean run

> Task :run
Hello, Susan Calvin
Execution took 2040 ms

Hello, Susan Calvin
Execution took 1034 ms

Footnotes

[1] Literature

Learn Concurrency in Kotlin by Miguel Angel Castiblanco Torre, July 2018.
(Packt Publishing (ISBN: 978-1-7886-2716-0).

mics/January 2025