Created main loop, thread, and exit method.