Class ThreadHelper

java.lang.Object
org.apache.groovy.util.concurrent.ThreadHelper

public final class ThreadHelper extends Object
Helper for starting threads that prefers virtual threads when running on Java 21+, falling back to platform threads on older runtimes.
Since:
6.0.0
  • Method Details

    • startThread

      public static Thread startThread(Runnable task)
      Starts a new thread to execute the given task. Uses a virtual thread on Java 21+, otherwise a platform thread.
      Parameters:
      task - the runnable to execute
      Returns:
      the started thread