Loading...

Thursday, 23 August 2012

Wait function in Java

 This function waiting n- ms
 
 public static void wait (int n){    
        long time1, time2;
        time1 =  System.currentTimeMillis();       
        do{
            time1 = System.currentTimeMillis();
        }while (time2 - time1 < n);
    }

If you want to set a sec change 'while ( time2 - time1 < n )' to 'while ( time2 - time1 < (n*1000) )'

No comments:

Post a Comment