RFR: 8360046: Scalability issue when submitting virtual threads with almost empty tasks [v5]

Viktor Klang vklang at openjdk.org
Wed Aug 27 08:52:44 UTC 2025


On Wed, 27 Aug 2025 05:32:36 GMT, He-Pin(kerr) <duke at openjdk.org> wrote:

>> Yes, it means we always adapt before calling submit, lazySubmit and externalSubmit rather than the mix of execute(Runnable) and xxxSubmit.
>
> If it's already a `AdaptedRunnable` should we adapt it too? if not, can we change the `ForkJoinTask.adapt` to something :
> 
>     public static ForkJoinTask<?> adapt(Runnable runnable) {
>         if (runnable instanceOf AdaptedRunnableAction action) 
>             return action
>          else   return new AdaptedRunnableAction(runnable);
>     }

Seems reasonable to do.


public static ForkJoinTask<?> adapt(Runnable runnable) {
    return (runnable instanceOf AdaptedRunnableAction adapted) ? adapted : new AdaptedRunnableAction(runnable);
}

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26479#discussion_r2303303217


More information about the core-libs-dev mailing list