Re: Multhithreading internals in GTK+
- From: jcupitt gmail com
- To: Vishwanath Venkatesan <venkates cs columbia edu>
- Cc: gtk-list gnome org
- Subject: Re: Multhithreading internals in GTK+
- Date: Wed, 2 Dec 2009 15:24:43 +0000
2009/12/2 Vishwanath Venkatesan <venkates cs columbia edu>:
> I am trying to understand the internals of threading in GTK+-2.0. From my
> understanding there are threads generated with GTK+ functions (ex. Opening a
> file-dialog) even without explicit threading.
That's not correct. Gtk+ is a single-threaded system with an event loop.
gtk_main() sits in a loop getting events from various sources and
dispatching them to various scraps of code according to the event
type. Each scrap of code will do a tiny bit of processing and then
return back to the main loop again. Everything runs in the same
You can have nested main loops: if you pop up a window, it can be a
programming convenience to have another main loop to handle the
interaction for that dialog, but it's not required. Again, the inner
main loop runs in the same thread.
If you want to have several threads in your application, it's usually
best to only have one of them doing all the gtk calls. You can use
some parts of glib to get worker threads to send safe messages to the
] [Thread Prev