CUSTOMISED
Expert-led training for your team
Dismiss

Kotlin Coroutines training course

An advanced workshop for experienced developers on Kotlin's coroutines and kotlinx.coroutines. Learn to write scalable, concurrent code using coroutine builders, structured concurrency, flows, and best practices.

JBI training course London UK

"Our tailored course provided a well rounded introduction and also covered some intermediate level topics that we needed to know. Clive gave us some best practice ideas and tips to take away. Fast paced but the instructor never lost any of the delegates"

Brian Leek, Data Analyst, May 2022

Public Courses

25/11/24 - 3 days
£2500 +VAT
06/01/25 - 3 days
£2500 +VAT
17/02/25 - 3 days
£2500 +VAT

Customised Courses

* Train a team
* Tailor content
* Flex dates
From £1200 / day
EDF logo Capita logo Sky logo NHS logo RBS logo BBC logo CISCO logo
JBI training course London UK

  • Introduction to Kotlin Coroutines
  • Explore styles of concurrency
  • Understand suspension mechanics
  • Dive into coroutines under the hood
  • Starting coroutines: builders & scope functions
  • Structured concurrency & CoroutineContext
  • Exception handling & constructing Coroutine Scope
  • Testing Kotlin Coroutines
  • Utilize Channels & Actors
  • Select expressions & Flow fundamentals
  • Flow lifecycle & processing
  • StateFlow & SharedFlow
  • Real-world use cases overview

Module 1: Introduction to Concurrency in Kotlin

1.1 Styles of Concurrency

  • Overview of Concurrency Models: Threads, Callbacks, Futures/Promises.
  • Concurrency Challenges: Race conditions, deadlocks, thread management.
  • Why Coroutines?: Benefits over traditional concurrency methods.

1.2 Overview of Common Use-Cases

  • Asynchronous Programming: Network calls, file I/O operations.
  • Parallel Processing: CPU-intensive tasks.
  • UI Interactions: Updating UI elements without blocking the main thread.

Module 2: Understanding Coroutines

2.1 Understanding How Suspension Works

  • Suspend Functions: Definition and usage.
  • Continuation Passing: How suspension resumes.
  • Call Stack and Coroutines: Differences from traditional functions.

2.2 Coroutines Under the Hood

  • Coroutine Mechanics: How Kotlin implements coroutines.
  • Lightweight Threads: Memory and performance benefits.
  • Coroutine States: Created, Active, Completed, Cancelled.

2.3 Starting Coroutines: Builders and Scope Functions

  • Coroutine Builders: launch, async, runBlocking.
  • Scope Functions: coroutineScope, supervisorScope.
  • Parent and Child Coroutines: Hierarchical structure.

2.4 Structured Concurrency

  • Principles of Structured Concurrency: Keeping coroutines manageable.
  • Scope Management: Ensuring coroutines complete or cancel together.
  • Error Propagation: Handling exceptions in coroutine hierarchies.

Module 3: Coroutine Context and Dispatchers

3.1 CoroutineContext

  • Context Elements: Job, Dispatcher, ExceptionHandler.
  • Manipulating Context: Adding and combining context elements.
  • Thread Local Data: Sharing data between coroutines.

3.2 Dispatchers

  • Default Dispatchers: Dispatchers.Default, Dispatchers.IO, Dispatchers.Main.
  • Custom Dispatchers: Creating and using custom thread pools.
  • Dispatcher Selection: Choosing the right dispatcher for tasks.

3.3 Understanding Job

  • Job Hierarchy: Parent and child jobs.
  • Job Lifecycle: States and transitions.
  • Job Control: Cancelling and joining jobs.

3.4 Cancellation

  • Cooperative Cancellation: How coroutines handle cancellation.
  • Cancellation Exceptions: Understanding CancellationException.
  • Timeouts: Using withTimeout and withTimeoutOrNull.

3.5 Exception Handling

  • Structured Exception Handling: try-catch within coroutines.
  • Exception Propagation: How exceptions travel in coroutine scopes.
  • Supervisor Jobs: Isolating failures with SupervisorJob and supervisorScope.

3.6 Constructing Coroutine Scope

  • Global Scope vs. Custom Scopes: Best practices.
  • Lifecycle-Aware Scopes: Tying coroutine scopes to application components.
  • Scope Cancellation: Managing scope lifecycle and cleanup.

Module 4: Advanced Coroutine Concepts

4.1 Testing Kotlin Coroutines

  • Testing Strategies: Unit testing suspend functions and coroutines.
  • Test Dispatchers: Controlling coroutine execution in tests.
  • Mocking and Verification: Using libraries like MockK or Mockito.

4.2 Channels

  • Introduction to Channels: Communication between coroutines.
  • Types of Channels: Rendezvous, buffered, conflated, unlimited.
  • Channel Operations: Sending, receiving, closing channels.

4.3 Actors

  • Actor Model: Encapsulating state and behavior.
  • Implementing Actors: Using actor coroutine builder.
  • Use-Cases for Actors: Managing shared mutable state safely.

4.4 Select Expression

  • Selective Communication: Handling multiple channel operations.
  • Timeouts and Defaults: Providing fallbacks in select expressions.
  • Use-Cases: Multiplexing input from multiple channels.

Module 5: Working with Flows

5.1 Understanding Flow

  • Cold Streams: Difference between sequences and flows.
  • Flow Builders: flow, flowOf, asFlow.
  • Flow Collection: Terminal operators like collect, toList.

5.2 Flow Lifecycle

  • Lifecycle of a Flow: Emission, collection, cancellation.
  • Backpressure Handling: Strategies for controlling data flow.
  • Exception Transparency: Handling errors in flows.

5.3 Flow Processing

  • Intermediate Operators: map, filter, transform, flatMapConcat.
  • Combining Flows: zip, combine, merging multiple flows.
  • Flow Context: Controlling the execution context with flowOn.

5.4 StateFlow and SharedFlow

  • StateFlow: Managing state in reactive applications.
  • SharedFlow: Hot streams and event sharing.
  • Comparison with Channels: When to use StateFlow or SharedFlow over channels.

Module 6: Best Practices

6.1 Concurrency Best Practices

  • Avoiding Common Pitfalls: Blocking threads, unstructured coroutines.
  • Optimizing Performance: Efficient use of dispatchers and contexts.
  • Thread Safety: Managing shared resources.

6.2 Coroutines in Real-world Applications

  • Integration with Android: Lifecycle-aware components.
  • Server-side Applications: Using coroutines with Ktor.
  • Migration Strategies: Converting callback-based code to coroutines.

6.3 Code Maintainability

  • Clean Code Principles: Writing readable and maintainable coroutine code.
  • Documentation: Commenting and documenting asynchronous flows.
  • Code Reviews: What to look for in coroutine implementations.
JBI training course London UK

Seasoned Kotlin Developers looking to get more out of their Kotlin code to help develop commercial applications on Google's Android platform or Backend Applications with Kotlin

5 star

4.8 out of 5 average

"Our tailored course provided a well rounded introduction and also covered some intermediate level topics that we needed to know. Clive gave us some best practice ideas and tips to take away. Fast paced but the instructor never lost any of the delegates"

Brian Leek, Data Analyst, May 2022



“JBI  did a great job of customizing their syllabus to suit our business  needs and also bringing our team up to speed on the current best practices. Our teams varied widely in terms of experience and  the Instructor handled this particularly well - very impressive”

Brian F, Team Lead, RBS, Data Analysis Course, 20 April 2022

 

 

JBI training course London UK

Newsletter

 

Sign up for the JBI Training newsletter to stay updated with world-class technology training opportunities, including Analytics, AI, ML, DevOps, Web, Backend and Security. Our Power BI Training Course is especially popular.  Gain new skills, useful tips, and validate your expertise with an industry-leading organisation, all tailored to your schedule and learning preferences.



By the end of this course, participants will have a deep understanding of Kotlin's concurrency tools, enabling them to write efficient, safe, and maintainable asynchronous code. They will be equipped with practical skills to implement coroutines and flows in various application scenarios, following industry best practices.

Join this advanced 3-day workshop designed for experienced developers, focused on mastering asynchronous programming in Kotlin using coroutines. You'll explore Kotlin's built-in coroutine support, delve into the powerful kotlinx.coroutines library, and learn how to write efficient, scalable, and maintainable concurrent code.

Topics include coroutine builders, structured concurrency, dispatchers, cancellation, channels, flows, and best practices to optimize your Kotlin projects for concurrency.

CONTACT
+44 (0)20 8446 7555

[email protected]

SHARE

 

Copyright © 2023 JBI Training. All Rights Reserved.
JB International Training Ltd  -  Company Registration Number: 08458005
Registered Address: Wohl Enterprise Hub, 2B Redbourne Avenue, London, N3 2BS

Modern Slavery Statement & Corporate Policies | Terms & Conditions | Contact Us

POPULAR

Rust training course                                                                          React training course

Threat modelling training course   Python for data analysts training course

Power BI training course                                   Machine Learning training course

Spring Boot Microservices training course              Terraform training course

Kubernetes training course                                                            C++ training course

Power Automate training course                               Clean Code training course