CodeGym
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • Scoped Values and new threading mechanics (Java 21+)

    JAVA 25 SELF
    Level 57, Lesson 4
    We break down why the classic ThreadLocal is losing relevance in the world of virtual threads, and how it is being replaced by ScopedValue: a context bound to an execution scope rather than a thread. Step-by-step examples of passing context (user, REQUEST_ID), nested scopes and their shadowing, integration with virtual threads ( Executors. newVirtualThreadPerTaskExecutor()). We discuss ThreadLocal vs ScopedValue, practical tips, limitations, and a look at Structured Concurrency (preview).
    Available
  • Structured Concurrency

    JAVA 25 SELF
    Level 58, Lesson 0
    Structured Concurrency turns a chaotic set of threads into a managed hierarchy of tasks: you launch subtasks in virtual threads within StructuredTaskScope, wait for them via join(), handle errors centrally with throwIfFailed(), and get results with resultNow()/ result(). We’ll examine the termination policies ShutdownOnFailure and ShutdownOnSuccess, compare them with CompletableFuture, look at HTTP aggregator examples, and cover common mistakes when using structured concurrency.
    Available
  • Canceling tasks and timeouts across the stack

    JAVA 25 SELF
    Level 58, Lesson 1
    How to correctly cancel long-running and blocking operations in Java: cooperative interruption via Thread.interrupt(), canceling tasks via Future.cancel() and the behavior of CancellationException, timeouts and cancellation in CompletableFuture ( orTimeout, completeOnTimeout), structured concurrency with StructuredTaskScope, a shared deadline (time budget) and propagating timeouts down the stack (including Instant/ Duration and Scoped Values). We cover practice with blocking I/O and common mistakes.
    Available
  • High-level synchronizers

    JAVA 25 SELF
    Level 58, Lesson 2
    In this lecture we cover high-level synchronizers from java.util.concurrent: CountDownLatch, CyclicBarrier, Phaser, and Exchanger. We learn to coordinate task start and completion via await()/ countDown(), build reusable phases and barrier actions with await(), manage dynamic members of the “orchestra” with register()/ arriveAndAwaitAdvance()/ arriveAndDeregister(), and exchange data in pairs via exchange(). In practice we implement a mass start of workers and a “game tick,” and also examine common mistakes: the one-shot nature of CountDownLatch, handling BrokenBarrierException, and proper deregister(). Everywhere we avoid the pain of wait()/ notify().
    Available
  • StampedLock and low-contention counters

    JAVA 25 SELF
    Level 58, Lesson 3
    When ReentrantReadWriteLock and the classic ReadWriteLock start to struggle under high load, StampedLock with optimistic reads comes to the rescue: the pair tryOptimisticRead + validate provides almost “free” reads when writes are rare. We’ll break down lock modes, working with stamps, reentrancy limitations, compare it with ReentrantReadWriteLock, and also look at low-contention counters — LongAdder and LongAccumulator — and why they outperform AtomicLong under contention. We’ll finish with hands-on practice: a read-dominant cache and a mini-benchmark.
    Available
  • Java Memory Model (JMM)

    JAVA 25 SELF
    Level 58, Lesson 4
    We break down the rules of visibility and operation ordering in the Java Memory Model: what the happens-before relation means, how and when volatile, synchronized, and final fields ( final) help, and why “stale” data appears without them. We will show safe publication of objects, correct double-checked locking, low-level access via VarHandle, the impact of false sharing and the @Contended annotation, as well as practical notes about Thread.start()/ Thread.join(), Future.get(), and JMH microbenchmarks.
    Available
  • Multithreaded file reading and writing

    JAVA 25 SELF
    Level 59, Lesson 0
    A practical guide to parallel file work in Java: when multithreading really speeds up I/O and when it doesn’t, choosing tools — Thread, thread pools via ExecutorService, async with CompletableFuture and parallel streams — plus reading large files in chunks via FileChannel, safe writes to a shared log, and OS/FS constraints. We break down task launch patterns, pool tuning, the shutdown()/ awaitTermination() methods, and common mistakes.
    Available
  • Parallel File Processing: ForkJoin, Parallel Streams

    JAVA 25 SELF
    Level 59, Lesson 1
    A practical guide to parallelizing file tasks in Java: how to enable parallelism in the Stream API using parallel()/ parallelStream(), how ForkJoinPool works and is configured, and when it’s better to use RecursiveTask. We’ll discuss where parallelism actually speeds up I/O, how to manage the common thread pool, and how to safely close resources ( try-with-resources). Finally—a quick look at positional access via FileChannel for reading/writing parts of large files.
    Available
  • Parallel FS traversals: Files.walk + parallel() and ForkJoin

    JAVA 25 SELF
    Level 59, Lesson 2
    How to speed up traversing large directories and processing thousands of files: use Files.walk() and parallel streams via parallel(), understand the role of ForkJoinPool.commonPool(), and tune the degree of parallelism. We explain when it’s better to switch to ExecutorService, how CPU-bound and IO-bound tasks differ, write an example that counts lines in all ".java" files, and capture best practices.
    Available
  • Splitting large files into chunks

    JAVA 25 SELF
    Level 59, Lesson 3
    How to speed up processing of gigabyte-scale files: split them into chunks (chunking), use positional access via FileChannel and memory-mapped buffers MappedByteBuffer, and parallelise computations with ExecutorService. We’ll cover key methods of positional I/O: position(...), read(...), write(...), criteria for choosing the chunk size, an example of parallel word counting, and typical mistakes (chunk boundaries, resources, number of threads).
    Available
  • File-processing pipelines: producer–consumer

    JAVA 25 SELF
    Level 59, Lesson 4
    We examine how to organize a file-processing pipeline using the Producer–Consumer pattern with safe exchange via a BlockingQueue (for example, ArrayBlockingQueue), how the blocking operations put() and take() work, why the backpressure mechanism is needed, and how to shut down threads correctly using a “poison pill” (for example, "__END__", not null). We launch consumers via ExecutorService, add a pipeline visualization, and go over common mistakes.
    Available
  • Introduction to Modules: Why They Are Needed

    JAVA 25 SELF
    Level 60, Lesson 0
    We break down why Java 9 introduced the module system JPMS: what’s wrong with the “ classpath-party,” how modules introduce visibility boundaries at the container level, what module-info.java is, and how to work with the module, exports, requires, opens, and uses/ provides directives. We’ll discuss benefits (encapsulation, explicit dependencies, security, jlink), use cases (including java.base, java.sql), useful nuances, and common migration mistakes (a forgotten exports, a missing requires, duplicate module names).
    Available
  • 1
  • ...
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym