Skip to content

L15: Contexts and Dispatchers

In this lesson we will explore:

  • Deep Theory: Elements of CoroutineContext, safe thread switching with withContext, specific roles of Dispatchers.IO, Dispatchers.Default, and Dispatchers.Unconfined, and exception handling with CoroutineExceptionHandler.
  • Under the Hood: How Dispatchers back onto adaptive JVM thread pools (ForkJoinPool / worker threads).
  • Incremental Lab (AI Chat CLI): Isolating blocking network calls to remote AI APIs onto Dispatchers.IO while processing token streaming on Dispatchers.Default.