glib: Use g_thread_get_initialized to check whether we have to call g_thread_init