I am looking for way to improve the way I read incoming data from the server. Right now I am using a while loop to catch the incoming data:
BufferedReader myReader = new BufferedReader(new InputStreamReader(mySocket.getInputStream()));
            read=myReader.readLine();
            String line;
            while (!read.contentEquals("stop")) {
                read = myReader.readLine().trim();
                if((line=read)!=null) {
                Thread Comm = new Thread(new CommThread(read));
                Comm.start();
                }
            }
I start a new Thread to handle incoming data (I want to send commands to the client) and prevent it from blocking the UI Thread. The Comm Thread will execute given commands.
I want the Bufferedreader to keep listening for new incoming data, but also I want to filter out the messages where nothing is coming.
Quick question: After the Bufferedreader reads an incoming message, is the message deleted from the InputStream?
Are there events like "OnRequestReceive" or something like that or am I bound to keep using while loops?
