there are times even the application is requesting for parallel processing, it could stick to one single thread without rotation.
for example, the case, https://lwpro2.dev/2021/06/11/jdk-spliterator-with-parallel-processing/.
this could be the case similar to thread affinity, https://en.wikipedia.org/wiki/Processor_affinity.
in java, to force the parallel processing, one way is to signal to the processor to rotate the time slicing.
stream.parallel() .peek(i -> { try { Thread.sleep(0); } catch (InterruptedException e) { e.printStackTrace(); } })
as such, even though the time quantum could be larger than the first phase tasks duration. the thread could volunteer to round robin the pool, which then the process could proceed with following parallel processing, instead of leaving to original single thread to handle the second phase tasks.
Published
Originally published at https://lwpro2.dev on June 15, 2021.