merlol has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I'm writing a perl Win32::GUI program.This program using multithreads, multithreads running is fine.i'm using Thread::Pool::Simple module for the multithreads.And using thread::shared for data sharing.Share is required for subroutines, so far everything is fine.Program when to use 2th subroutine for the print the array to screen, GUI crashes so GUI not wait the thread or not print array element;
System: Perl version (v5.12.4) built for MSWin32-x86-.. Binary build 1205 294981
Windows 7
Thank you, Regards.use Win32::GUI; use threads; use threads::shared; my @SHARED; share(@SHARED); (...) &GET(@otherdata); #example (...) #1th subroutine sub GET { @data = @_; (...) sub workder { $data_2 = shift; (...) (...) for(...){ push(@SHARED, $_); } (...) } my $pool2 = Thread::Pool::Simple->new( min => 3, max => 20, do => [\&workder] ); foreach $getdatas (@data) { (...) } $pool2->join(); (...) &GET_2(); } #2th subroutine sub GET_2 { print $_,"\n" for @SHARED; #@SHARED not printing to screen }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: thread::share problem
by BrowserUk (Patriarch) on May 12, 2012 at 12:50 UTC | |
by merlol (Initiate) on May 12, 2012 at 21:53 UTC | |
by BrowserUk (Patriarch) on May 12, 2012 at 23:07 UTC | |
by Anonymous Monk on May 13, 2012 at 01:45 UTC | |
by BrowserUk (Patriarch) on May 13, 2012 at 08:26 UTC | |
| |
by merlol (Initiate) on May 13, 2012 at 02:03 UTC |