首页 > IT职业 > IT生活 > 匿名内部类,回调... (转)
int i = 1;
public A() {
Thread thread = new Thread() {
public void run() {
for(;;) {
A.this.run();
try {
sleep(1000);
} catch(InterruptedException ie) {
}
}
}
};
thread.start();
} 
public void run() {
System.out.println("i = " + i);
i++;
}
public static void main(String[] args) throws Exception {
new A();
}
}来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10790690/viewspace-961355/ ,如需转载,请注明出处,否则将追究法律责任。