我尝试定期在JavaFX应用程序后台线程中运行,这会修改一些GUI属性.
我想我知道如何使用Task和Service类,javafx.concurrent并且无法弄清楚如何在不使用Thread#sleep()方法的情况下运行这样的周期性任务.如果我可以使用一些Executor来自Executors制造方法(Executors.newSingleThreadScheduledExecutor())会很好
我试图Runnable每5秒运行一次,重启javafx.concurrent.Service但它会立即挂起,service.restart甚至service.getState()被调用.
所以最后我使用Executors.newSingleThreadScheduledExecutor(),它Runnable每隔5秒发射一次并使用以下命令Runnable运行另一个Runnable:
Platform.runLater(new Runnable() {
//here i can modify GUI properties
}
Run Code Online (Sandbox Code Playgroud)
它看起来非常讨厌:(有没有更好的方法来使用Task或Service类?
我正在玩转移,我对一个案件感到困扰:
int maxint = Integer.MAX_VALUE;
LOG.debug("maxint << 31 ---> {} ({})", maxint << 31 , Integer.toBinaryString(maxint << 31 ));
LOG.debug("maxint << 32 ---> {} ({})", maxint << 32 , Integer.toBinaryString(maxint << 32 ));
LOG.debug("maxint << 33 ---> {} ({})", maxint << 33 , Integer.toBinaryString(maxint << 33 ));
Run Code Online (Sandbox Code Playgroud)
它打印:
maxint << 31 ---> -2147483648 (10000000000000000000000000000000)
maxint << 32 ---> 2147483647 (1111111111111111111111111111111)
maxint << 33 ---> -2 (11111111111111111111111111111110)
Run Code Online (Sandbox Code Playgroud)
所以问题是如果换档31在MSB处留下'1'然后换档32不应该将其移出并返回0?
更进一步,我从shift 31结果(Integer.MIN_VALUE)开始,然后移动1.
int minInt = -2147483648;
LOG.debug("minInt << 1 ---> {} ({})", minInt …Run Code Online (Sandbox Code Playgroud)