Mam pewniem problem.
Otóż mam klasę
class Odbior implements Runnable
{
public List list1;
public Odbior() {}
public void run()
{
while (true)
{
try{
Socket s1 = new Socket ("localhost",1234);
InputStream s1In = s1.getInputStream();
DataInputStream dis = new DataInputStream(s1In);
String st = new String(dis.readUTF());
//dos.writeUTF(st);
System.out.println(st);
System.out.println("Test");
list1.add(st);
list1.add("------------------");
s1.close();
}
catch(IOException e)
{
//System.out.println("Błąd");
}
}
}
}
Jednak nie działa jak powinna.
Chodzi o to żeby podczas odbioru tekstu od innego klienta ten tekst mi sie wyświetlał.
Teraz nic się nie dzieje, nawet słowo "Test" się nie wyświetla.
Klase uruchamiam
Odbior odp = new Odbior();
(new Thread(odp)).start();