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