# Effective Kotlin Item 2: Eliminate critical sections

DevFeed: [Effective Kotlin Item 2: Eliminate critical sections](<https://devfeed.tech/articles/effective-kotlin-item-2-eliminate-critical-sections-39292.md>)

Original publisher: [Read original article](<https://kt.academy/article/ek-synchronization>)

Published: 2023-08-28T00:00:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Concurrency](<https://devfeed.tech/topics/concurrency.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Concurrent Programming](<https://devfeed.tech/topics/concurrent-programming.md>), [Operating system](<https://devfeed.tech/topics/operating-system.md>)

Tags: [bugs](<https://devfeed.tech/tags/bugs.md>), [collections](<https://devfeed.tech/tags/collections.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [critical](<https://devfeed.tech/tags/critical.md>), [execution](<https://devfeed.tech/tags/execution.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [state](<https://devfeed.tech/tags/state.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

## AI overview

This tutorial explains why concurrent modifications to shared mutable state can produce lost updates and incorrect object states. It introduces threads, time slicing, and synchronization concerns in Kotlin/JVM, using an incrementing-variable example and discussing bugs involving collections.

## Source excerpt

Learn why do we need to synchronize access to mutable state, and how to secure it.