I have a situation in an app, where there are a lot of network calls of the same endpoint (with different parameters) at the same time. This can cause other calls to be blocked.

The setup uses Retrofit + Kotlin Coroutines.

One solution I can think of is to run the calls with different instances of Retrofit+OkHttp using separate thread pools.

However, I'd prefer a single thread pool (and Retrofit instance) defining limitations via different kotlin coroutine dispatchers and the use of [limitedParallelism()](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-main-coroutine-dispatcher/limited-parallelism.html).

See this code snippet:

```kotlin
class NetworkApi(
    private val retrofitWebserviceApi: RetrofitWebserviceApi,
    threadPoolExecutor: ThreadPoolExecutor,
    private val dispatcher: CoroutineDispatcher = threadPoolExecutor.asCoroutineDispatcher()
        .limitedParallelism(CoroutineDispatcherConfig.ioDispatcherLimit),
    // A separate IO dispatcher pool so the many calls to getEntries don't block other calls
    private val noParallelismDispatcher: CoroutineDispatcher = dispatcher.limitedParallelism(1),
) {
    /**
     * Represents an endpoint, which needs to be called with a lot of different 
     * parameters at the same time (about 1000 times).
     * It's important these calls don't block the whole thread pool.
     */
    suspend fun getEntries(description: String) = withContext(noParallelismDispatcher) {
        retrofitWebserviceApi.getEntries(description)
    }

    /**
     * This call should not be blocked by [getEntries] calls, but be executed shortly after it is called.
     */
    suspend fun getCategories() = withContext(dispatcher) {
        retrofitWebserviceApi.getCategories()
    }
}

```

Full executable JVM code sample here: [github sample code - question branch](https://github.com/p-fischer/coroutines-retrofit-limitparallism/tree/question)

So the idea here is to limit parallel requests using Kotlin Coroutine Dispatchers.
However, the project logs show that OkHttp uses its own OkHttp Dispatcher.

Is there a way to de-activate the OkHttp Dispatcher and just run a network call in the current thread (defined by a Coroutine Dispatcher here)?

Is this possible without losing the possibility to cancel requests?

Thanks for your help!