Re: Threads
- From: Olexiy Avramchenko <olexiy ctech cn ua>
- To: Russell Shaw <rjshaw netspace net au>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Threads
- Date: Wed, 15 Dec 2004 13:57:33 +0200
Russell Shaw wrote:
Hi,
In the faq on threads (http://www.gtk.org/faq/#AEN482), there is:
int
main (int argc, char *argv[])
{
GtkWidget *window;
/* init threads */
g_thread_init(NULL);
gdk_threads_init();
/* init gtk */
gtk_init(&argc, &argv);
window = create_window();
gtk_widget_show(window);
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
return 0;
}
Because gdk_threads_enter()/leave() surround gtk_main(), then
wouldn't that mean other threads that use gdk_threads_enter()/leave()
are always blocked until gtk_main() exits?
Hello,
No, gtk_main unlocks mutex before g_main_loop_run() call and then GDK
code locks it just before gtk_main_do_event() call. So, mutex is locked
only when event is processing.
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]