I have some questions regarding the usage of QThread, and I'm hoping someone here can give me a couple pointers. I've read the documentation and the examples on the usage of QThread, but there are some finer points that I must be missing.

First, some background. I'm writing a multi-player puzzle game. The project is being tackled in two pieces: a game server, and a game client. The server will handle all game control and logic, and will have only rudimentary visual display (printf statements to a console... maybe). The client will communicate with the server via TCP/IP and will be responsible for the GUI aspects of the game.

The server class inherits QThread directly. The game flow is such that the server is basically a large state machine, so it doesn't do anything (except track a timer) unless messages come in from the clients. When a message comes in, the server parses it and takes appropriate action. I'd like the server to take as little time as possible so that there's plenty of CPU left for the graphical aspects of the client.

Here's where the questions begin -

1) The documentation states that in order for the thread to handle events, I need to invoke exec(). Do I need to invoke exec() repeatedly (eg in a while( !gameOver ) loop), or just once?

2) Does exec() return immediately when invoked? That is, when does code execution in the thread continue?

3) The documentation mentions that when run() exits the thread stops execution. Am I correct in believing that this would render the thread incapable of handling events? I guess the real question is whether or not I need a captive loop in the run() routine.

Thanks in advance for any help!