<lambda>null1@file:JvmMultifileClass 2 @file:JvmName("ThreadPoolDispatcherKt") 3 package kotlinx.coroutines 4 5 import java.util.concurrent.* 6 import java.util.concurrent.atomic.AtomicInteger 7 8 @DelicateCoroutinesApi 9 public actual fun newFixedThreadPoolContext(nThreads: Int, name: String): ExecutorCoroutineDispatcher { 10 require(nThreads >= 1) { "Expected at least one thread, but $nThreads specified" } 11 val threadNo = AtomicInteger() 12 val executor = Executors.newScheduledThreadPool(nThreads) { runnable -> 13 val t = Thread(runnable, if (nThreads == 1) name else name + "-" + threadNo.incrementAndGet()) 14 t.isDaemon = true 15 t 16 } 17 return executor.asCoroutineDispatcher() 18 } 19