views:

20

answers:

0

Hi,

I want to be able to handle input from a server through a Socket and pass it to a method to process it. I am trying to implement this through a class that implements runnable, with a loop in the run statement such as:

public void run()  
{  
while(notDisconnected)   
      {  
      line = readLineFromServer();  
      if (!(line==null))      
          handleServerMessage();  
      Thread.sleep(250);  
      }  
}  

However, this only runs once and then hangs, with no error or exceptions. Am I doing anything wrong? Can anyone suggest a better method than this?