Created
October 4, 2025 03:06
-
-
Save anandwana001/ce17bd7da11bf154fd0d10a2e1626b5d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun main() = runBlocking { | |
| println("Main thread: ${Thread.currentThread().name}") | |
| launch(Dispatchers.Unconfined) { | |
| println("1. Unconfined - Start: ${Thread.currentThread().name}") | |
| delay(100) | |
| println("2. Unconfined - After delay: ${Thread.currentThread().name}") | |
| withContext(Dispatchers.Default) { | |
| println("3. Inside Default: ${Thread.currentThread().name}") | |
| } | |
| println("4. Unconfined - After withContext: ${Thread.currentThread().name}") | |
| } | |
| delay(200) | |
| } | |
| /* Output (example): | |
| Main thread: main | |
| 1. Unconfined - Start: main | |
| 2. Unconfined - After delay: kotlinx.coroutines.DefaultExecutor | |
| 3. Inside Default: DefaultDispatcher-worker-1 | |
| 4. Unconfined - After withContext: DefaultDispatcher-worker-1 | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment