code: void compute_sleep_time() {
  	if (works.size() > 0) {
  	    double next, after_d, diff;
  	    WorkItem item = (WorkItem) works.elementAt(0);
  
  	    next = item.wake_up_date.tv_sec + (double) item.wake_up_date.tv_usec / 1000000;
  	    after_d = after.tv_sec + (double) after.tv_usec / 1000000;
  	    diff = next - after_d;
  
  	    if (diff < 0) {
  		if (Util.fabs(diff) < Tango_DISCARD_THRESHOLD) {
  		    sleep = 0;
  		} else {
  		    while (diff < 0 && Util.fabs(diff) > Tango_DISCARD_THRESHOLD) {
  			Util.out5.println(diff + " > " + Tango_DISCARD_THRESHOLD);
  			Util.out5.println("Discard one elt !!!!!!!!!!!!!");
  			item = (WorkItem) works.elementAt(0);
  			compute_new_date(item.wake_up_date, item.update);
  			insert_in_list(item);
  			works.remove(0);
  
  			item = (WorkItem) works.elementAt(0);
  			next = item.wake_up_date.tv_sec + (double) item.wake_up_date.tv_usec
  				/ 1000000;
  			diff = next - after_d;
  		    }
  		    if (Util.fabs(diff) < Tango_DISCARD_THRESHOLD) {
  			sleep = 0;
  		    } else {
  			sleep = (long) (diff * 1000);
  		    }
  		}
  	    } else {
  		sleep = (long) (diff * 1000);
  	    }
  	    Util.out5.println("Sleep for : " + sleep);
  	}
      }
docs: ===============================================================