类 VirtualThreadTaskExecutor

java.lang.Object
cn.taketoday.core.task.VirtualThreadTaskExecutor
所有已实现的接口:
AsyncTaskExecutor, TaskExecutor, Executor

public class VirtualThreadTaskExecutor extends Object implements AsyncTaskExecutor
A TaskExecutor implementation based on virtual threads in JDK 21+. The only configuration option is a thread name prefix.

For additional features such as concurrency limiting or task decoration, consider using SimpleAsyncTaskExecutor.setVirtualThreads(boolean) instead.

从以下版本开始:
4.0
作者:
Juergen Hoeller, Harry Yang
另请参阅:
  • 字段详细资料

    • virtualThreadFactory

      private final ThreadFactory virtualThreadFactory
  • 构造器详细资料

    • VirtualThreadTaskExecutor

      public VirtualThreadTaskExecutor()
      Create a new VirtualThreadTaskExecutor without thread naming.
    • VirtualThreadTaskExecutor

      public VirtualThreadTaskExecutor(String threadNamePrefix)
      Create a new VirtualThreadTaskExecutor with thread names based on the given thread name prefix followed by a counter (e.g. "test-0").
      参数:
      threadNamePrefix - the prefix for thread names (e.g. "test-")
  • 方法详细资料

    • getVirtualThreadFactory

      public final ThreadFactory getVirtualThreadFactory()
      Return the underlying virtual ThreadFactory. Can also be used for custom thread creation elsewhere.
    • execute

      public void execute(Runnable task)
      从接口复制的说明: TaskExecutor
      Execute the given task.

      The call might return immediately if the implementation uses an asynchronous execution strategy, or might block in the case of synchronous execution.

      指定者:
      execute 在接口中 Executor
      指定者:
      execute 在接口中 TaskExecutor
      参数:
      task - the Runnable to execute (never null)