public static Thread virtualThreadIfSupported(String name, Runnable target) {
    if (THREAD_OF_VIRTUAL_CLASS == null) {
      return new Thread(target, name);
    }
    Object builder = ReflectionUtil.invokeMethod(Thread.class, OF_VIRTUAL);
    ReflectionUtil.invokeMethod(builder, THREAD_OF_VIRTUAL_NAME, name);
    return (Thread) ReflectionUtil.invokeMethod(builder, THREAD_OF_VIRTUAL_UNSTARTED, target);
  }
Creates a virtual thread if supported by the current JVM.

@param name the name of the thread
@param target the target to run on the thread
@return the created thread
spock-core/src/main/java/org/spockframework/util/ThreadSupport.java