public static long waitTillNextMillisec ( long currentMillisec ) { long nextMillisec = System . currentTimeMillis ( ) ; for ( ; nextMillisec <= currentMillisec ; nextMillisec = System . currentTimeMillis ( ) ) { Thread . yield ( ) ; } return nextMillisec ; }
Waits till clock moves to the next millisecond .