I\'m using Java to create games. Here\'s engine script:
public void start() { if (running) return; running = true; thread = new Thread(th