我试图在满足某个条件时弹出一个窗口,但是当满足条件时。窗口没有打开。我正在使用 Thread.sleep
代码:
public void grow() {
Thread thread = new Thread(() -> {
try {
Thread.sleep(this.harvestTime);
if(water >= waterNeeded && fertelizer >= fertelizerNeeded) {
this.harvest = true;
AlertBox.display("CROP ALERT","A SEED HAS FINISHED GROWING");
Thread.sleep(60000);
if(harvest == true) {
withered = true;
harvest = false;
AlertBox.display("ALERT", "FAILED TO HARVEST A CROP. IT BECAME WITHERED!");
}
}
else {
this.withered = true;
}
} catch (Exception e) {
}
});
thread.start();
}
相关分类