views:

45

answers:

0
void forloop2()
{
    int i = 0;
    while(TRUE)
    {
        printf("forloop2\n");
    }
}

int main() {
    GtkWidget *window;
    g_thread_init(NULL);
    gdk_threads_init();
    g_thread_create((GThreadFunc)forloop2, NULL, FALSE, NULL);
    gtk_init(NULL, NULL);
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show_all (window);
    gtk_main();
}

It seems the created thread affects gtk_window_new(my programe hangs here),

how do I do it correctly?

UPDATE

fixed by gdk_threads_enter/leave