* Wake up when new operations are scheduled or the last operation is committed
* Called by MainProgram thread
*/
- synchronized void waitFor() {
+ synchronized long waitFor() {
- mainProgram.assertMainProgramThread();
+ mainProgram.assertMainProgramThread();
- // One last check within the monitor
- if(!operations.isEmpty() || !tasks.isEmpty()) return;
+ // One last check within the monitor
+ if(!operations.isEmpty() || !tasks.isEmpty()) return 0;
- try {
- wait(5000);
- } catch (InterruptedException e) {
- LOGGER.error("Unexpected interruption", e);
- }
+ long start = System.nanoTime();
+ System.err.println("start =" + start);
+
+ try {
+ wait(5000);
+ } catch (InterruptedException e) {
+ LOGGER.error("Unexpected interruption", e);
+ }
+
+ return System.nanoTime() - start;
}