@@ -111,7 +111,11 @@ public static Supplier<IntUnaryOperator> nMultiplyFunctionSupplier(int n) {
111111 * @return a thread supplier
112112 */
113113 public static Supplier <Thread > runningThreadSupplier (Runnable runnable ) {
114- throw new UnsupportedOperationException ("It's your job to implement this method" ); // todo
114+ return () -> {
115+ Thread thread = new Thread (runnable );
116+ thread .start ();
117+ return thread ;
118+ };
115119 }
116120
117121 /**
@@ -120,12 +124,16 @@ public static Supplier<Thread> runningThreadSupplier(Runnable runnable) {
120124 * @return a runnable consumer
121125 */
122126 public static Consumer <Runnable > newThreadRunnableConsumer () {
123- throw new UnsupportedOperationException ( "It's your job to implement this method" ); // todo
127+ return runnable -> new Thread ( runnable ). start ();
124128 }
125129
126130
127131 public static Function <Runnable , Supplier <Thread >> runnableToThreadSupplierFunction () {
128- throw new UnsupportedOperationException ("It's your job to implement this method" ); // todo
132+ return runnable -> () -> {
133+ Thread thread = new Thread (runnable );
134+ thread .start ();
135+ return thread ;
136+ };
129137 }
130138
131139 /**
@@ -138,7 +146,7 @@ public static Function<Runnable, Supplier<Thread>> runnableToThreadSupplierFunct
138146 * @return a binary function that receiver predicate and function and compose them to create a new function
139147 */
140148 public static BiFunction <IntUnaryOperator , IntPredicate , IntUnaryOperator > functionToConditionalFunction () {
141- throw new UnsupportedOperationException ( "It's your job to implement this method" ); // todo
149+ return ( intOperation , intPredicate ) -> a -> intPredicate . test ( a ) ? intOperation . applyAsInt ( a ) : a ;
142150 }
143151
144152 /**
@@ -147,7 +155,7 @@ public static BiFunction<IntUnaryOperator, IntPredicate, IntUnaryOperator> funct
147155 * @return a supplier instance
148156 */
149157 public static Supplier <Supplier <Supplier <String >>> trickyWellDoneSupplier () {
150- throw new UnsupportedOperationException ( "It's your job to implement this method" ); // todo
158+ return () -> () -> () -> "WELL DONE!" ;
151159 }
152160}
153161
0 commit comments