Thread Tk & threads: shared variable in Label? (4 answers)
Opened by pktm at 2005-09-23 21:14

Strat
 2005-09-23 23:33
#44630 #44630
User since
2003-08-04
5246 Artikel
ModeratorIn
[Homepage] [default_avatar]
ich vermute, dass Tk mit der shared variable probleme hat...
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use warnings;
use strict;

use threads;
use threads::shared;

my $runs : shared = 0;
#my $thr1 = threads->new(\&startGui, \$runs);
my $thr2 = threads->new(\&startRequest, \$runs);

#$thr1->join();

my $x = 0;
require Tk;
my $mw = Tk::MainWindow->new();
$mw->packPropagate(0);
$mw->Label(-textvariable => \$x)->pack();
$mw->repeat(200, sub { $x = $runs; $mw->update });
$mw->MainLoop();

$thr2->join();


sub startRequest {
while(1) {
lock $runs;
$runs++;
print "run $runs\n";
sleep(1);
}
} # /startRequest
perl -le "s::*erlco'unaty.'.dk':e,y;*kn:ai;penmic;;print"
http://www.fabiani.net/

View full thread Tk & threads: shared variable in Label?