问题是我的函数在使用setInverval()后只执行一次。任何人都知道如何解决它,所以蛇对象的update()方法实际上一遍又一遍地运行?
以下是代码:
final private long feedbackValue = 0x87654321;
private long state;
public void initialize(long initialValue) {
int count = 0;
state = feedbackValue ^ initialValue;
System.out.println("State "+count+":"+ String.format("0x%08X",state));
while (count < 8) {
update();
count++;
System.out.println("State "+count+":"+ String.format("0x%08x",state));
}
}//end initialize method
private void update() {
if ((state & 1) == 0) {
state = state >>> 1;
} else {
state = (state >>> 1)^feedbackValue;
}
}//end update method