in reply to External controlling of a multi-threaded Windows perl program
You can isolate shared variables so that each thread has it's own, by setting up a hash (or array) of shared vars, one for each thread. Here is an examle Tk-with-worker-threads. Remember, with Tk, you need to start all threads before any Tk code is called. That means you will need to predefine the number of threads available, and possibly reuse them. Gtk2 (GLib) has better thread safety, and if you are very lucky you may be able to dynamically create threads. I have been testing this idea from time to time, and it is NOT foolproof. Sometimes it works, sometimes a segfault, sometimes a memory gain. So the same advice applies to Gtk2 as to Tk: create your threads first before any GUI code is called for rock-solid performance. But you may want to switch to Gtk2 (GLib) for better thread safety, if you need to dynamically spawn threads.
The only other alternative is to use POE. It has no gui code, and may allow dynamic threads without problems.
|
|---|