private synchronized TaskHolder nextTask() {
    do {
      long currentTime = System.currentTimeMillis() - timeDiff;
      for (int i = 0, n = list.size(); i < n; i++) {
	TaskHolder h = (TaskHolder) list.get(i);
	if (h.time <= currentTime) {
	  list.remove(i);
	  return h;
	}
      }
      try {
	wait(1000);
      } catch (Exception e) {
	e.printStackTrace();
      }
    } while (true);
  }