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

Reply via email to