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

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • Threads vs virtual threads: differences and advantages

    JAVA 25 SELF
    57 level,0 lecture
    We’ll examine how platform threads differ from virtual ones: how the “ Platform Thread → OS” model works and why it’s heavy, what changes with virtual threads ( Virtual Thread) on top of carrier threads, and how this delivers scalability without reactive “spaghetti.” We’ll look at practical usage with Thread.ofVirtual(), compare behaviour for I/O‑bound and CPU‑bound tasks, touch on compatibility (blocking calls like InputStream.read, Socket.accept) and common mistakes (legacy synchronisation, expecting “magical speedups”).
    Open
  • Creating virtual threads: Thread.ofVirtual().start()

    JAVA 25 SELF
    57 level,1 lecture
    Hands-on with Java 21 virtual threads: how they differ from platform threads, how to start them via Thread.startVirtualThread(...) and Thread.ofVirtual().start(...), when new Thread(...) or Thread.ofPlatform() is still appropriate, and how to execute tasks at scale using Executors.newVirtualThreadPerTaskExecutor(). We’ll cover waiting for completion via join(), error handling with Future and ExecutionException, and common pitfalls when using virtual threads.
    Open
  • Scalability and Performance of Virtual Threads

    JAVA 25 SELF
    57 level,2 lecture
    A practical comparison of platform threads Thread and virtual threads in Java 21: how the JVM, thanks to “ carriers” (carrier threads), executes hundreds of thousands of tasks with minimal memory; where virtual threads shine (I/O-bound) and where they don’t (CPU-bound). We’ll examine limitations ( synchronized, native locks), best practices ( Executors.newVirtualThreadPerTaskExecutor()), monitoring via JVisualVM and Java Flight Recorder, as well as common mistakes when migrating to Virtual Threads.
    Open
  • Using Executor with virtual threads

    JAVA 25 SELF
    57 level,3 lecture
    We will break down how to run one task in a single virtual thread using Executors.newVirtualThreadPerTaskExecutor() (Java 21), how this differs from classic pools ( newFixedThreadPool, newCachedThreadPool), how to shut down properly via shutdown() and awaitTermination(...), how to get task results via Future, and where virtual threads deliver the biggest wins (mass I/O, web servers, load testing). At the end — common mistakes and gotchas.
    Open
  • Scoped Values and new threading mechanics (Java 21+)

    JAVA 25 SELF
    57 level,4 lecture
    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).
    Open
Courses
  • Java Course
  • Python Course
  • Development with Claude Code
  • All 16 courses
University
  • Java FullStack
  • Python FullStack
  • AI Native Developer
  • Web FullStack
Community
  • Articles
  • Forum
  • Help with Tasks
Company
  • About us
  • Contacts
  • Reviews
  • Pricing
  • Questions and answers
JavaRush JavaRush: online courses in Java and other programming languages, where you learn by solving tasks. We started in 2012 with a Java course, and today there are 16 courses: Java and Spring, Python, web development, SQL, Go, C#, C++, Kotlin, Swift, Docker and AI development. More than 10,000 tasks with instant checks, and the first level of any course is free. Learn on your own or with a mentor at JavaRush University.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush Terms of Use and Privacy policy
MastercardVisa
"Programmers are not born" © 2026 JavaRush Terms of Use and Privacy policy