I'm making an instant messenger in java and using a thread to check if there are any received messages. But for some reason it only loops through the while loop in my run method once. I put a print line at the beginning of the loop and it a print line before the only statement where it can terminate itself and I don't see either one of those print statements (except I see the fist one, once). I also go no error messages and my application isn't frozen. Why does it only loop once?
By the way. I know it's messenger, not messanger. But it's only a test application so I'm not going to sniff out all my variables over one misspelling.
Code java:BufferedReader in; String incomingMessage; Thread t; public MessageReciever(BufferedReader i) { in = i; t = new Thread(this); t.start(); } public void run() { try { while(true) { System.out.println("1"); try { if((incomingMessage = in.readLine()) != null) MessangerDisplay.append(incomingMessage); } catch(IOException e) { System.out.println("x"); MessangerDisplay.append("The user has dropped."); stop(); } t.sleep(50); } } catch(InterruptedException e2) { MessangerDisplay.append("Thread interrupted."); } }
http://img714.imageshack.us/img714/8482/36378009.png

