All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.javasimon.testapp.test.Runner Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
package org.javasimon.testapp.test;

import org.javasimon.Split;
import org.javasimon.SimonManager;

/**
 * Class Runner.
 *
 * @author Radovan Sninsky
 * @since 2.0
 */
public class Runner {

	private Controller controller;
	private Timer timer;

	private boolean run = true;

	public Runner(Controller controller, Timer timer) {
		this.controller = controller;
		this.timer = timer;
	}

	public void run() {
		int runno = 0;
		try {
			while (run) {
				Split s = SimonManager.getStopwatch("org.javasimon.testapp.action").start();
				controller.next().perform(++runno);
				s.stop();

				long d = timer.delay();
				System.out.println(" -- Delay: " + d + " ms\n");
				s = SimonManager.getStopwatch("org.javasimon.testapp.delay").start();
				Thread.sleep(d);
				s.stop();
			}
		} catch (InterruptedException e) {
			// do nothing
		}
	}

	public void stop() {
		run = false;
		Thread.currentThread().interrupt();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy