Please help me to understand the disadvantage of Thread-Pool pattern using NIO.
I found this Question: Java NIO non-blocking mode vs node.js asychronous operation but it do not answer how NIO affects scheduling behaviour in java.
How I understand Node.js and java.IO:
Node.js uses Event loop and non-blocking IO combined with callbacks. This allows to process other tasks while IO-call not finished like this:
Using old java.IO library and thread pool pattern the java thread get blocked till IO operation is completed. In the meantime the thread can not process other tasks and barred from scheduling.
But now. What about NIO? Consider we have a thread pool with max 10 threads.
Every thread get some job as Runnable
object.
So what will happen if a long-term IO operation is required. I can't believe that the current undone Runnable
will be replaced by other till the initial IO call is completed.
So how exactly changes java.NIO
the scheduling behaviour in Java by comparison with java.IO
?