I get an InputStream from a TCP connection and read from it (via BufferedReader). When receiving a message, my program will process that request. This includes some database operations. It will do so continuously in a while loop (TCP long connection).
Schematically it looks like this:
while(!clientSocket.isClosed()) {
in.read(request);
// process request
}
What happens, if a new message arrives, while my program is still busy processing the previous request? Will it be "stored" and fetched with the next in.read() call? Or do I have to create a thread for the database operations to not miss requests?