5 Einträge, 1 Seite |
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
#!/Perl/bin/perl
use strict;
use warnings;
use threads;
use threads::shared;
my $runs : shared = 0;
my $thr1 = threads->new(\&startGui, \$runs);
my $thr2 = threads->new(\&startRequest, \$runs);
$thr1->join();
$thr2->join();
sub startGui {
require Tk;
my $mw = Tk::MainWindow->new();
$mw->packPropagate(0);
$mw->Label(-textvariable => \$runs)->pack();
$mw->MainLoop();
} # /startGui
sub startRequest {
while(1) {
$runs++;
print "run $runs\n";
sleep(1);
}
} # /startRequest
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
5 Einträge, 1 Seite |