Event-driven Socket Programming
807605Aug 29 2007 — edited Sep 1 2007I've developed an application that communicates with a device over TCP/IP. Right now I have an infinite loop in another thread that continually checks for data on the socket, calling Thread.sleep() each time to prevent the receive thread from using the entire CPU, but I think this may be limiting my throughput. I'd like to either find a class that will generate an event for me when data arrives (which I'm doing myself at present), or be able to call wait() and have my thread notify()ed when data arrives on the socket. Can either of these things be done?