I experienced this I think you need to create your TK GUI AFTER you create your threads. I'm not really sure why but when one of those threads ends, it's trying to kill your main window, as if the object was shared (even though I know you didn't specify that it should be). Somehow those other threads get a hold of your TK objects and try to destroy them when they quit.
I do have a program that uses TK and 1 single thread. I had to rewrite it to get it to work as well. I also got frustrated and redesigned it so that the worker thread didn't die until the entire program comes to an end. However I don't think that is necessary. GL, and Hope this helps. -Wayne Simmons > -----Original Message----- > From: Hale, Bruce E [mailto:[EMAIL PROTECTED] > Sent: Friday, January 09, 2004 10:55 AM > To: [EMAIL PROTECTED] > Subject: TK and threads (with join) problem > > Has anyone successfully been able to use Perl/TK and threads at the same > time? I have run into a problem where I can run threads but if I use > thread->join then I run across problems with respect to program > termination in one case (shown below) or where the thread hash list gets > fouled up (much larger program causes this). For example, the code > snippit below returns an error on completion (this error does not occur if > I remove either the "$mw = new MainWindow" line or the "$ReturnData = > $thr[$i++]->join;" line). > > Thanks for your help, > > Bruce > > ===> The code snippit is as follows: <=== > > use Tk; > use Tk::DialogBox; > use threads; > > # Create main window. > $mw = new MainWindow; > > @prtList = ("a", "b", "c"); > $thr0 = threads->new(\&printer, $prtList[0]); > $thr1 = threads->new(\&printer, $prtList[1]); > $thr2 = threads->new(\&printer, $prtList[2]); > > $ReturnData = $thr0->join; > print "Thread returned $ReturnData\n"; > $ReturnData = $thr1->join; > print "Thread returned $ReturnData\n"; > $ReturnData = $thr2->join; > print "Thread returned $ReturnData\n"; > > > sub printer { > my $prtchar = $_[0]; > print "$prtchar\n"; > return $prtchar; > } > > > ==> Program Output <=== > > a > b > Thread returned a > c > Thread returned b > Thread returned c > 15db2a8 is not a hash at C:/Perl/site/lib/Tk/Widget.pm line 96 during > global destruction > > abnormal program termination > > _______________________________________________ > ActivePerl mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
