Kotlin Interview Questions for Coroutines and Concurrency

1. What are coroutines in Kotlin, and how do they simplify asynchronous programming?

2. What is the difference between `launch` and `async` in Kotlin coroutines?

3. What is `runBlocking`, and when should it be used?

4. What are suspension functions, and how do they work in Kotlin coroutines?

5. What is the role of `CoroutineScope` in Kotlin, and why is it important?

6. What are `Dispatchers` in Kotlin coroutines, and how do they control coroutine execution?

7. What is `GlobalScope` in Kotlin, and why should its usage be limited?

8. What is structured concurrency in Kotlin, and why is it important?

9. What is `withContext` in Kotlin coroutines, and how does it differ from `launch`?

10. What are coroutine exceptions, and how can they be handled in Kotlin?

11. How does the coroutine lifecycle work internally in Kotlin?

12. What is `SupervisorJob`, and how does it differ from a regular `Job`?

13. How does the `yield` function work in Kotlin coroutines?

14. What is `Flow` in Kotlin, and how does it handle concurrency?

15. What is `ThreadLocal` in Kotlin coroutines, and how is it managed?

16. How does `coroutineScope` differ from `runBlocking` in Kotlin?

17. What is the role of `Job` in Kotlin coroutines?

18. What are `CancellationException`s in Kotlin coroutines, and how are they handled?

19. How does `SupervisorScope` handle exceptions in coroutines?

20. What is the difference between `flatMapMerge`, `flatMapConcat`, and `flatMapLatest` in Kotlin Flow?