Sunday, 25 August 2013

display delay of update with threading and swing

display delay of update with threading and swing

I have a thread updating my swing interface each time launched.Even though
i worked with the invokeLater() method of SwingUtilities class i still
have this delay.
This the run of my thread code:
public void run() {
final int timeout=2000;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
if
(InetAddress.getByName(host).isReachable(timeout)){
ServerFrame.listModel.addElement(InetAddress.getByName(host).getHostName()
+ '\n');
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}});
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Ant this is how i call it
for (int i =63;i<66 ;i++){
ping p = new ping("192.168.1."+i);
p.start();}

No comments:

Post a Comment