Hello everyone,
I am continuing my talk from another thread and thought that this is a whole other issue in itself.
I would like to start my main application and create two threads, one to process some data and one to initialize and start the QT GUI. (Why I don't just make my GUI the core of the application is another story).
I am able to do this and compile everything, however, the GUI Thread seems to take over and all other threads seem to be blocked (or not getting any cpu time), including the main thread.
Here's a sample of my code:
void *initUI(char *argv[]) {
hpgeUI(argv); //this function does all the QApplication, exec() stuff
return 0;
}
void *process() {
printf("This is the process thread\n");
return 0;
}
int main(int argc, char *argv[])
{
pthread_t guithread, process;
pthread_create(&guithread, NULL, initUI(argv), 0);
//CHECK PT 1
pthread_create(&process, NULL, process, 0);
while(1)
{
//do something here
}
return 0;
}
void *initUI(char *argv[]) {
hpgeUI(argv); //this function does all the QApplication, exec() stuff
return 0;
}
void *process() {
printf("This is the process thread\n");
return 0;
}
int main(int argc, char *argv[])
{
pthread_t guithread, process;
pthread_create(&guithread, NULL, initUI(argv), 0);
//CHECK PT 1
pthread_create(&process, NULL, process, 0);
while(1)
{
//do something here
}
return 0;
}
To copy to clipboard, switch view to plain text mode
Any ideas as to why this is happening? The GUI is showing up and seems to hijack all the resources of the application; no other threads are created and CHECK PT 1 is not reached.
Regards,
BB
Bookmarks