Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Beginner
Aug 10, 1999



Application Security Testing: An Integral Part of DevOps

Nonblocking I/O

Say I have 10 sockets and I want to have a thread which checks for a message from the sockets using their InputStreams. The thread will wait in the first socket until it receives a message in that socket. How can I skip to the next socket when there is no message in the current socket?

There is no analog to select() in Java, nor is there true nonblocking I/O. The proper way to check if an InputStream has any data available for reading is to call its available() method and see if it returns a positive value. The proper way to check if a Reader has any data available for reading is to call its ready() method and see if it returns true.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date