code: public static long waitTillNextMillisec(long currentMillisec) {
          long nextMillisec = System.currentTimeMillis();
          for (; nextMillisec <= currentMillisec; nextMillisec = System.currentTimeMillis()) {
              Thread.yield();
          }
          return nextMillisec;
      }
docs: Waits till clock moves to the next millisecond.
  
  @param currentMillisec
  @return the "next" millisecond