# Sleepless Concurrency: delay() vs. Thread.sleep()

DevFeed: [Sleepless Concurrency: delay() vs. Thread.sleep()](<https://devfeed.tech/articles/sleepless-concurrency-delay-vs-thread-sleep-25750.md>)

Original publisher: [Read original article](<https://blog.shreyaspatil.dev/sleepless-concurrency-delay-vs-threadsleep/>)

Author: Shreyas Patil

Published: 2023-07-31T04:39:30Z

Content type: article

Language: en

Sources: [Shreyas Patil's Blog](<https://devfeed.tech/sources/shreyas-patil-s-blog.md>)

Topics: [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Distributed Systems & Parallel Computing](<https://devfeed.tech/topics/distributed-systems-parallel-computing.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [blocking](<https://devfeed.tech/tags/blocking.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [coroutine](<https://devfeed.tech/tags/coroutine.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [delay](<https://devfeed.tech/tags/delay.md>), [java](<https://devfeed.tech/tags/java.md>), [jvm](<https://devfeed.tech/tags/jvm.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-coroutines](<https://devfeed.tech/tags/kotlin-coroutines.md>), [main-thread](<https://devfeed.tech/tags/main-thread.md>), [multithreading](<https://devfeed.tech/tags/multithreading.md>), [sleep](<https://devfeed.tech/tags/sleep.md>), [thread](<https://devfeed.tech/tags/thread.md>)

## AI overview

On a single thread, coroutine `delay()` suspends the coroutine without blocking the thread, allowing other coroutines to run; Java `Thread.sleep()` blocks the thread, preventing them from running until sleep ends. In the excerpt's two-coroutine example with a 1,000 ms wait, both coroutines launch in the same second with `delay()`, and total execution takes 1,045 ms; with `sleep()`, the second launches about one second later and total execution takes 2,044 ms. The excerpt frames the APIs as serving different use cases.

## Source excerpt

Explore the difference between delay() and Thread.sleep() in Kotlin. Understand how non-blocking concurrency works from a platform perspective.