Java Virtual Threads Throughput

Поділитися
Вставка
  • Опубліковано 8 чер 2024
  • Virtual threads, the long-awaited headline feature of Project Loom, became a final feature in JDK 21. Virtual threads are the start of a new chapter of concurrency in Java by providing developers with lightweight threads, allowing the easy and resource-cheap breaking up of tasks to be executed concurrently. However, with these changes come questions about how to manage this throughput best. Let's take a look at how developers can manage throughput when using virtual threads.
    Article: inside.java/sip/094
    ~~~ Chapters ~~~
    0:00 Intro
    0:29 Creating Virtual Threads
    1:33 Rate Limiting Virtual Threads
    2:35 Configuring Platform Threads
    3:18 Debugging Virtual Threads
    Tags: #Java #OpenJDK #jdk21
  • Наука та технологія

КОМЕНТАРІ • 27

  • @31redorange08
    @31redorange08 4 місяці тому +2

    2:01 The code is wrong. The acquire() should be right before the try, not inside.

    • @FikriHaikal-he4bg
      @FikriHaikal-he4bg 4 місяці тому

      Does it even mather?

    • @juliandurchholz
      @juliandurchholz 4 місяці тому +2

      Incorrect, acquire throws InterruptedException.

    • @31redorange08
      @31redorange08 4 місяці тому

      @@juliandurchholz Then we need two try blocks.

    • @juliandurchholz
      @juliandurchholz 4 місяці тому

      @@31redorange08 I see, in case the acquire is interrupted, the semaphore would still be released erroneously.

    • @billykorando6820
      @billykorando6820 4 місяці тому

      Oh yea, good catch, I'll need to update the code in the article. Thanks!

  • @mohammadtoficmohammad3594
    @mohammadtoficmohammad3594 4 місяці тому +2

    Thank you for the information

  • @user-ek1ls8ol7d
    @user-ek1ls8ol7d 3 місяці тому

    so good😺

  • @user-pi9cj2or5n
    @user-pi9cj2or5n 4 місяці тому

    Great feature!

  • @ngspace9829
    @ngspace9829 4 місяці тому +9

    "Tomcatty" 💀

    • @Zolnierzu
      @Zolnierzu 4 місяці тому +5

      Tom, Katty, and Jetty

    • @stefanobaghino
      @stefanobaghino 4 місяці тому +2

      Code Tomcatty, not spaghetti.

    • @billykorando6820
      @billykorando6820 4 місяці тому +4

      Yea facepalmed when I realized that in editing. Feel I played it off smooth though 😎

  • @juliandurchholz
    @juliandurchholz 4 місяці тому

    Hoping to see pluggable schedulers added to Loom soon. Currently, virtual threads have identical priority and run on the same pool of carrier threads, which lacks the control that true high-performance applications desire. A priority scheduler and multiple carrier pools would be much appreciated.

  • @ax8635
    @ax8635 4 місяці тому +2

    Is there any complete tutorial covering Virtual Threads?

  • @rokkralj9786
    @rokkralj9786 4 місяці тому

    I have a problem - I set maxPoolSize to just 4, but around 30 platform threads are created. I can see that in HTOP, which is able to list all platform threads of a process.

  • @csm2526
    @csm2526 4 місяці тому

    Virtual threads internally using FORKJOINPOOL and are slow compared to FORKJOINTASK. I executed the same factorial program with input 10000000 takes 6 hr using FORKJOINTASK where as it take 20 hr using virtual thread.

    • @ThaRealiestJEDI
      @ThaRealiestJEDI 3 місяці тому

      You misuse VT. They don't speed up computations, they allow to do easily do I/O operations in non-blocking manner.

    • @csm2526
      @csm2526 3 місяці тому

      @@ThaRealiestJEDI performing non blocking I/O is the only purpose of creating VT, then NIO is there to do the same. Why VT?

    • @ThaRealiestJEDI
      @ThaRealiestJEDI 3 місяці тому

      @@csm2526 I/O is also networking db access. You don't have nio for Http Clients. Without VT system thread is blocked until you got response.

    • @ThaRealiestJEDI
      @ThaRealiestJEDI 3 місяці тому

      @@csm2526 Networking or DB communication is also I/O operation and you don't have NIO there.