private synchronized void recordElapsedTime ( ) { // do nothing if the timer is not started if ( startTime == 0 ) return ; long current = System . nanoTime ( ) ; // It is reported that elapsed time can be negative on some platforms. // Use the absolute difference to avoid infinite waits. timeWaited += Math . abs ( current - startTime ) ; // continue timing from now startTime = current ; }
Record the elapsed time and continue timing from now .