When using threads you must take care that the initialisation is done in the correct order, so that other library functions do not alter the internal state due to expecting something else to be there because the initialisation was done in the wrong order.
To quote the manual entry for gdk_threads_init()
This call must be made before any use of the main loop from GTK+; to be safe, call it before gtk_init().
But no where in your code sample do you show that any of this is possible and that you must have done many more GTK calls before initialising the GDK threading system.
Using threads can be difficult at the best of times as without care you could create an application that works great on your system, but totally fails unexpectedly on another machine.
Take care and please take the time to read the manual page for the GDK threads http://developer.gnome.org/gdk/stable/gdk-Threads.html
and take note of the line in the manual
You must call g_thread_init() and gdk_threads_init() before executing any other GTK+ or GDK functions in a threaded GTK+ program.