Unix Programming - How to write a multithread gtk program

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > July 2005 > How to write a multithread gtk program





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to write a multithread gtk program
Zheng Da

2005-07-07, 5:54 pm

I want to use gtk and pthread to write a program.

I have written such a program, and found it's difficult to operate gtk
widgets in other threads.I have to call gdk_threads_enter() to enter a
critical region when I want to operate gtk widgets, and have to call
gdk_threads_leave() to leave a critical region after operating it.It
seems very hard to do it, and there are a lot of problems when I call
gdk_threads_enter().
For example, the main thread calls pthread_cancel() to cancel a thread,
calls pthread_join() to waits, and the canceled thread calls a cleanup
call-back function. If the function call gdk_threads_enter(), the whole
program will stop.

I read the source code of gftp, and found gftp only operated gtk
widgets in the main thread, and update the interface every second.

But is there a better way to operate gtk widgets if I change some
states in other threads, and want to update the interface at once?

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com