Using Channels with threads for a data pipeline


I’m a kotlin newbie using channels to implement a data pipeline. for higher throughput of data i need threads. i’ve implemented it the following way:

first i’m creating threads

 val threads = Array(workers) {

then I assign them

 val consumer = Array(workers) {
         produce(threads[it]) {
             println("${Thread.currentThread().name} Start Consumer")

So I’m asking, is this a ok? is there a better way to do it?



Can you avoid to use a dedicated thread pool?
Are you considered built-in dispatchers?


Well the question is, can i avoid a dedicated thread pool, if i want max throughput? which built in dispatchers could i use as alternative? thx!


Yes, you can.
See dispatchers documentation for further details.