You can solve that by re-orienting the code a litt...
# coroutines
m
You can solve that by re-orienting the code a little bit. Create a fixed thread pool and have each thread infinite-loop on a queue (don't worry about shutdown for the moment). In its loop, dequeue a number, do your processing (re-using that
IntArray
), and then put the result in another queue.