1、 用Thread就不会iu无法终止
new Thread(new Runnable() {
public void run() {
while (true) {
test();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void test() {
// TODO Auto-generated method stub
}
public Runnable start() {
// TODO Auto-generated method stub
return null;
}
}.start());
2、 或者用现成的
javax.swing.
new Thread(new Runnable() {
public void run() {
while (true) {
test();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void test() {
// TODO Auto-generated method stub
}
public Runnable start() {
// TODO Auto-generated method stub
return null;
}
}.start());
2、 或者用现成的
javax.swing.