@Override
	public void run() {
		Thread thisThread = Thread.currentThread();
		long beforeTime, timeDiff, sleep;
		while (state == State.START && simulator == thisThread) {

			for (Body b : list) {
				calculateVectors(b);
				calculateMovement(b);
			}
			checkCollision();

			beforeTime = System.currentTimeMillis();
			timeDiff = System.currentTimeMillis() - beforeTime;
			sleep = delay - timeDiff;
			if (sleep < 0) {
				sleep = 2;
			}
			try {
				Thread.sleep(sleep);
				if (state == State.PAUSE) {
					synchronized (this) {
						while (state == State.PAUSE && simulator == thisThread)
							wait();
					}
				}
			} catch (InterruptedException e) {
				System.out.println("Interrupted: " + e.getMessage());
				for (Body b : list) {
					b.lineUp(list.indexOf(b));
					;
				}
			}

			beforeTime = System.currentTimeMillis();
		}
	}