Posted By

mamoo on 10/09/08


Tagged

java delay


Versions (?)

Simple delay


 / Published in: Java
 

  1. protected void delay(long milliseconds) throws Exception{
  2. Calendar now = Calendar.getInstance();
  3. while ((Calendar.getInstance().getTimeInMillis() - now.getTimeInMillis()) < milliseconds){}
  4. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: toolkit on October 17, 2008

This will hog your CPU! At least call sleep!!

Posted By: ILoveBeer on October 20, 2008

omg!!! very cpu consuming!!! use int ms = 500;
try { Thread.sleep(ms); } catch (InterruptedException e) {}

instead

You need to login to post a comment.