private void waitForNextRecord ( long startingTime , long timestamp ) { if ( mFirstTimestamp == 0 ) { mFirstTimestamp = timestamp ; Log . d ( TAG , "Storing " + timestamp + " as the first " + "timestamp of the trace file" ) ; } long targetTime = startingTime + ( timestamp - mFirstTimestamp ) ; long sleepDuration = Math . max ( targetTime - System . currentTimeMillis ( ) , 0 ) ; try { Thread . sleep ( sleepDuration ) ; } catch ( InterruptedException e ) { } }
Using the startingTime as the relative starting point sleep this thread until the next timestamp would occur .