JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Success stories
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • Why file I/O blocks and how it affects the choice of Dispatchers

    Kotlin SELF
    56 level,0 lecture
    We break down the difference between suspension and thread blocking, why JVM file operations are most often blocking, and how this directly affects the choice of coroutine context: where to use Dispatchers.Default, and where to use Dispatchers.IO. Using examples with withContext, async, and the blocking Thread.sleep, we show how “accidental I/O on Default” can slow down CPU tasks, and how the discipline “I/O separately, CPU separately” simplifies architecture.
    Open
  • withContext(Dispatchers.IO) + use {}: correct boundaries for I/O functions

    Kotlin SELF
    56 level,1 lecture
    We break down how, in Kotlin coroutines, to properly separate blocking file I/O from CPU logic: where to put withContext( Dispatchers.IO), how to safely exit via return@withContext, why you need use { ... } to close resources, and why a “wide” IO context turns into a trash bin for responsibility. At the end: hands-on practice for the File Organizer utilities and a list of common mistakes.
    Open
  • Parallel file processing — async + awaitAll()

    Kotlin SELF
    56 level,2 lecture
    We break down a practical pattern for concurrent processing of many files in Kotlin coroutines: how launch and async differ, how to batch-collect results with awaitAll(), why it’s dangerous to “start a thousand tasks at once”, how to limit concurrency with Dispatchers.IO.limitedParallelism(n), where the boundary between I/O and CPU lies, and how to integrate this into structured concurrency via coroutineScope.
    Open
  • Cancellation in long-running file operations: chunk loop, isActive, CancellationException

    Kotlin SELF
    56 level,3 lecture
    We break down cooperative coroutine cancellation in long-running file operations: why blocking I/O “doesn’t hear” cancel(), why you need a chunk loop (read/write in chunks), where to place cancellation points via isActive and ensureActive(), how to work correctly with CancellationException (and not “silence” it in catch), and also how to cancel a task from the outside via cancelAndJoin().
    Open
  • Partial results and cleanup: temp files, renaming, cleanup

    Kotlin SELF
    56 level,4 lecture
    We break down a practical strategy for reliable “publishing a result” when working with files: write to a draft ( .tmp/ .part), then atomically (as much as possible) “publish” via renameTo(), and in any case perform best-effort cleanup in finally. Using Kotlin and coroutines examples: try / finally, withContext( Dispatchers. IO), the deleteQuietly helper, safe report writing, and a wrapper for copying.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success stories
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush