https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

sreich

04/07/2017, 5:33 PM
also i'm trying to use
newFixedThreadPoolContext
to create a fixed amount of threads to run my function on..but i think i need to know the thread id it's running on (0 or 1..n)
e

elizarov

04/07/2017, 5:38 PM
What exactly your are trying to achieve?
s

sreich

04/07/2017, 5:40 PM
i have work that can be done on an array, but only in a multithreaded manner if they are in separate sections of the array. my previous solution was just spawning n threads and partitioning their 'region' into n parts. now i wanna use coroutines and use the job/channel stuff
before it was essentially
for n in 1..4 { thread { dostuff(threadNum=n) } }
, but now i wanna try using coroutines (and the channel/producer classes) with a fixed number of threads
or is there a better approach?
e

elizarov

04/07/2017, 6:29 PM
You can do the same with coroutines. Just replace
thread
with
launch(CommonPool)
5 Views