" , 1 ?" - , ( ), ( ).
" ?" - ( ). , , , . , , , , .
"Are there any dangers when trying to use this super fast timer?" - as you wrote above, “quick search on the map, where millis is the key”, you use millis as the key, but you will not start every millisecond so that your logic if the account is damaged.
static int inc = 0;
public static void main(String[] args) throws InterruptedException {
TimerTask timerTask = new TimerTask() {
public void run() {
inc++;
}
};
Timer timer = new Timer(true);
timer.scheduleAtFixedRate(timerTask, 0, 1);
Thread.sleep(500000);
timer.cancel();
timer.purge();
System.out.println(inc);
}
source
share