in reply to Running a threaded Tk script on Windows

One issue might be the fact that you've loaded Tk, which is an XS module, and then spawned threads, which attempts to duplicate the data (even though you only use the Tk objects from one of the threads). The way around this is to replace your use Tk and use Tk::Something statements with require statements and place these after the point in the code where you launch your threads.

Update: to give proper credit, I got this idea from BrowserUk in a node I can't find but it might have been this one.

Replies are listed 'Best First'.
Re^2: Running a threaded Tk script on Windows
by zentara (Cardinal) on Sep 15, 2005 at 22:53 UTC
    Thanks for the ideas. But I do spawn the threads before I start any Tk code, and it does run fine on linux. But it's a good possibility that windows needs the "use Tk" after the threads are up and running.

    I'm also wondering if it has something to do with using $ENV{tz} on windows?


    I'm not really a human, but I play one on earth. flash japh
      Thanks for the ideas. But I do spawn the threads before I start any Tk code, and it does run fine on linux.
      Just because it works on linux doesn't mean its supposed to :) and the mere act of useing the module executes code. From perlthrtut
      If you're using a module that's not thread-safe for some reason, you can protect yourself by using it from one, and only one thread at all. If you need multiple threads to access such a module, you can use semaphores and lots of programming discipline to control access to it.
      Tk is not thread-safe.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

        Well, I rewrote a Windows version which loads and starts the threads before I require any Tk modules, and it still fails. It just brings back all the nightmares which made me dump Windows to begin with. Screw Windows!! ;-)

        I'm not really a human, but I play one on earth. flash japh