@Override
	public synchronized void run() {
		while (!done) {
			try {
				while (!paused) {
					if (count > 0) {
						Core.cycle(1);
						count--;
						updatecount--;
					} else if (infloop) {
						Core.cycle(1);
						updatecount--;
					} else {
						tv.updateDisplay(); // update when we pause/stop running code
						paused = true;
					}
					if (updatecount<=0) {
						tv.updateDisplay();
						updatecount=UPDATECOUNT;
					}
					Thread.yield();
				}
				wait();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}