If I call read() on a DataInputStream, will it take up CPU cycles waiting for data or does it yield the current thread and get woken up by an interrupt signaling that data has arrived?
My motivation for asking the question is to determine whether or not a stream reader needs to be in its own thread or not. A blocking read that takes up CPU time would not be ideal as this would hang the main thread.
Related question: When a method is described as a blocking, does it IMPLY that the thread yields while waiting? Or is there no contract/guarantee? A method that constantly checks/polls for data still blocks, it sounds, to me.
Please let me know.