Does the example I sent work if you add package require Tk for the first thread? I probably am using wish - but you could also, right?I've written multiple production apps that are multi-threaded and use Tk - I've never had a problem with it. That's not to say there couldn't be anything, but it has worked well for me.Also, due to the threading model that tcl uses, there is not that much advantage to using threading in tcl unless you specifically want to use the thread-shared-variables or other thread-specific features. Threads in tcl are a lot more seperated from each other than is common in threaded programming, so in many cases you're nearly just as well off exec-ing a sub process to run something that would normally be threaded, and communicating with it via stdin/stdout. This introduces some complications, sure, but it also often improves some things. It's usually worth at least considering.RustyOn Nov 2, 2011, at 9:50 AM, Duquette, William H (318K) wrote:I suspect that the difference is that your tclkit is functionally a "wish", whereas I'm running in "tclsh" and doing "package require Tk".As for using Tk in multiple threads--all of the documentation I've seen on the Threads package that mentions Tk (as, for example, _Practical Programming in Tcl and Tk_) says not to do it. It's not that it will fail immediately, but that it (under circumstances usually difficult to reproduce or debug) it will fail mysteriously.Will--Will Duquette -- William.H.Duquette@jpl.nasa.govAthena Development Lead -- Jet Propulsion Laboratory"It's amazing what you can do with the right tools."On 11/1/11 6:43 PM, "Rusty Brooks" <firstname.lastname@example.org> wrote:I just tried and it works perfectly fine btw. Also, I didn't have to do any kind of thread::wait or anything like that, seems to work OK as is with the setup I have (which is using a tclkit with the thread libraries built in)
See attached script
On 11/1/2011 4:36 PM, Duquette, William H (318K) wrote:Howdy!
1. I know that I can only use Tk in a single thread of a multi-threaded app. Does it matter which thread it is, i.e., if Tk is NOT running in the main thread is it OK to invoke it in a thread created using thread::create?
(I've tried it; it appears to work; I just need to know whether it will cause me problems in the long run.)
2. When I invoke Tk using [package require Tk] in a thread created using thread::create, it appears that I have to call [vwait] or [thread::wait] explicitly at the end of the thread startup script, or I don't enter the event loop. Is this expected behavior?
Thanks very much!
Will--Will Duquette -- William.H.Duquette@jpl.nasa.govAthena Development Lead -- Jet Propulsion Laboratory"It's amazing what you can do with the right tools."
------------------------------------------------------------------------------ RSA® Conference 2012 Save $700 by Nov 18 Register now! http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________ Tcl-Threads mailing list Tcl-Threads@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/tcl-threads