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:
https://try.kotlinlang.org/#/UserProjects/7t1259klqnaa4q494pghbkmso5/dtljtf4dpo1dmbcl7irqvseru6
first i’m creating threads
val threads = Array(workers) {
newSingleThreadContext("worker-${it}")
}
then I assign them
val consumer = Array(workers) {
produce(threads[it]) {
println("${Thread.currentThread().name} Start Consumer")
...
send("finished")
}
}
So I’m asking, is this a ok? is there a better way to do it?
Thanks!