@@ -99,6 +99,12 @@ private static ThreadFactory defaultThreadFactory() {
9999 return Thread .ofVirtual ().factory ();
100100 }
101101
102+ /** Similar to {@link #open(ThreadFactory, Policy, Joiner)}, but uses a default thread factory. */
103+ public static <T , R > TaskGroup <T , R > open (
104+ Policy <? super T > policy , Joiner <? super T , ? extends R > joiner ) {
105+ return new TaskGroup <>(defaultThreadFactory (), policy , joiner );
106+ }
107+
102108 /**
103109 * Opens a new task group with the given policy and joiner. It should be used with
104110 * try-with-resources statement like:
@@ -111,10 +117,15 @@ private static ThreadFactory defaultThreadFactory() {
111117 *
112118 * <p>The calling thread becomes the task group's owner and is the only thread allowed to call
113119 * {@link #fork}, {@link #join} or {@link #close} on it.
120+ *
121+ * <p>A new thread is created using the given {@code threadFactory} for each subtask. If the
122+ * factory returns {@code null}, a {@link RejectedExecutionException} is thrown.
114123 */
115124 public static <T , R > TaskGroup <T , R > open (
116- Policy <? super T > policy , Joiner <? super T , ? extends R > joiner ) {
117- return new TaskGroup <>(defaultThreadFactory (), policy , joiner );
125+ ThreadFactory threadFactory ,
126+ Policy <? super T > policy ,
127+ Joiner <? super T , ? extends R > joiner ) {
128+ return new TaskGroup <>(threadFactory , policy , joiner );
118129 }
119130
120131 /**
0 commit comments