public void run() {
DatagramPacket d = null;
byte[] buf = new byte[1024];
d = new DatagramPacket(buf, buf.length);
try {
while (true) {
socket.receive(d);
sb.append(d.getData().toString());
}
} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace();
} finally {
socket.close();
}
}
这个线程中如何将receive接收到的信息传出本线程,还不让它停止循环? |