Re: Gthreads again



Fernando Apesteguía wrote:
The main thread is the only one that is running inside the gtk_main loop.
The secondary thread is only reading files. So if I do a gtk_main_quit() the
secondary thread will be no longer running because I have not a gtk_main
loop, right?

Wrong, the main thread is not running inside the gtk_main loop, the
gtk_main is running inside an arbitrary thread (happens to be the
main one); if you call gtk_main_quit(); then gtk_main() (in the main
thread) will return and the main thread will continue to execute
(typicly untill the "return 0" a few lines later on).

If I'm right why I had to explicitly kill the other thread when it was
created with pthread instead of g_thread?

There is no reason why you dont have to explicitly kill the GThread,
if there is a race condition with your old code, there is still
a race in the GThread version.

Cheers,
                        -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]