is there a way to time a certain method, like if you want something to happen at a certain time?


1 2 3 4 5 | if (timer > 0 ) { timer--; if (timer == 0 ) methodName(); } |
1 2 3 4 5 6 | private void checkTimer() { if (timer == 0 ) return ; // the timer is not in use timer--; if (timer == 0 ) methodName(); } |
1 2 | timer--; if (timer == 0 ) methodName(); |
1 2 3 4 5 | if (System.currentTimeMillis() - timer >= 1000 ) { timer = 0 ; methodName(); } |