diff --git a/core/src/main/scala/org/apache/spark/util/ThreadUtils.scala b/core/src/main/scala/org/apache/spark/util/ThreadUtils.scala index 26d85439ec92d..bb65e7cbe9185 100644 --- a/core/src/main/scala/org/apache/spark/util/ThreadUtils.scala +++ b/core/src/main/scala/org/apache/spark/util/ThreadUtils.scala @@ -161,8 +161,14 @@ private[spark] object ThreadUtils { * Construct a new Java ForkJoinPool with a specified max parallelism and name prefix. */ def newForkJoinPool(prefix: String, maxThreadNumber: Int): ForkJoinPool = { + /** + * Extend ForkJoinWorkerThread so we can instantiate it. + */ class SparkForkJoinWorkerThread(pool: ForkJoinPool) extends ForkJoinWorkerThread(pool) { } + /** + * Custom ForkJoinWorkerThreadFactory to specify the thread name. + */ class SparkForkJoinFactory extends ForkJoinPool.ForkJoinWorkerThreadFactory { override def newThread(pool: ForkJoinPool): ForkJoinWorkerThread = { val th = new SparkForkJoinWorkerThread(pool) @@ -171,6 +177,9 @@ private[spark] object ThreadUtils { } } val factory = new SparkForkJoinFactory() - new ForkJoinPool(maxThreadNumber, factory, null /* handler */, false /* asyncMode */) + new ForkJoinPool(maxThreadNumber, factory, + null, // handler + false // asyncMode + ) } }