in reply to convert a single thread application to multithread with GUI
1. If you use Tk, you must create all your threads before any Tk is invoked. This usually involves reusing threads, and letting them sleep when not used. You cannot manipulate Tk widgets from the threads, except by signalling through shared variables.
2. If you use Gtk2, you can use it's Glib thread-safe mechanism, and launch threads as you need them, AND manipulate Gtk2 objects from the threads, but Gtk2 is a bit trickier to set up. It is still safer to reuse threads, but you may see if disposible threads work for you. If you detach threads, they are disposible, if you don't detach, then you must join them later.
3. For immediate termination of threads, you need to tell it to return. This is usually done through shared variables.
4. Tons of code examples have been posted, just search here or groups.google search.
For a basic Gtk2 example, with thread-reuse, see Threads-w-Perl/Gtk2 demo </code>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: convert a single thread application to multithread with GUI
by ultibuzz (Monk) on Jul 11, 2007 at 13:08 UTC | |
by zentara (Cardinal) on Jul 11, 2007 at 13:17 UTC | |
by ultibuzz (Monk) on Jul 11, 2007 at 13:49 UTC | |
by zentara (Cardinal) on Jul 11, 2007 at 16:14 UTC | |
by ultibuzz (Monk) on Jul 12, 2007 at 11:34 UTC | |
|