in reply to Re^3: Annoying threads share problem!
in thread Annoying threads share problem!
P.S. Use code blocks around your code examples.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::MatchEntry; use threads; use threads::shared; my %shash; my %hash; my @choices; share $shash{'go'}; share $shash{'die'}; share @choices; $shash{'go'} = 0; $shash{'die'} = 0; @choices = ( "01234", "345345", "64364" ); $hash{'thread'} = threads->new(\&work); my $mw = MainWindow->new( -title => "MatchEntry Test" ); #print Dumper(@choices); my $full_PathMatchEntry = $mw->MatchEntry( -width => 10, -choices => \@choices, -autopopup => 0, -complete => 1, -ignorecase => 1, -maxheight => 15, -background => "#FFFFFF" )->pack( -fill => 'x', -expand => 1, -side => 'left' ); $full_PathMatchEntry->focus; $full_PathMatchEntry->bind( '<KeyPress>', [ sub { shift; my $w = shift; $w->show_listbox(); }, $full_PathMatchEntry ] ); $mw->Button(-text=>'Do_Thread', -command=> sub { $shash{'go'} = 1; $mw->after(1000); $full_PathMatchEntry->configure(-choices => \@choice +s); })->pack(); MainLoop; sub work{ $|++; while(1){ if($shash{'die'} == 1){ goto END }; if ( $shash{'go'} == 1 ){ push( @choices, "/dfgsdfgsdfgsfse/ertuy/" ); $shash{'go'} = 0; #turn off self before returning }else { sleep 1 } } END: }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Annoying threads share problem!
by Ace128 (Hermit) on Oct 10, 2005 at 04:30 UTC | |
by zentara (Cardinal) on Oct 10, 2005 at 09:11 UTC | |
by Ace128 (Hermit) on Oct 10, 2005 at 12:25 UTC | |
by zentara (Cardinal) on Oct 10, 2005 at 17:31 UTC | |
by Ace128 (Hermit) on Oct 10, 2005 at 19:19 UTC |