0
SwingUtilities
클래스의 invokeLater()
메서드로 작업했지만 새 스윙 인터페이스를 시작할 때마다 스레드가 업데이트됩니다.이 지연 시간은 여전히 있습니다.스레딩 및 스윙을 통한 업데이트 지연 표시
이 내 스레드 코드의 실행 :
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();
}
}
개미이 내가 그것을 호출하는 방법입니다
for (int i =63;i<66 ;i++) {
ping p = new ping("192.168.1."+i);
p.start();
}
[동시 실행 (Concurrency in Swing)] (http://docs.oracle.com/javase/tutorial/uiswing/concurrency/)에서 특히 ['SwingWorker'] (http : // docs .oracle.com/javase/tutorial/uiswing/concurrency/worker.html)이 목적을 위해 설계되었습니다 ... – MadProgrammer