use strict; use warnings; use Tk; use threads; my $cnt = 0; my $mw = MainWindow->new(); $mw->Button( -text => 'print', -command => sub { my $time = localtime(); $cnt++; threads->new(\&print_bon, $cnt, $time); }, )->pack(-anchor => 'center', -pady => '2'); MainLoop; sub print_bon { my $cnt = shift; my $time = shift; sleep rand(10); print "Ausdruck $cnt ($time)\n"; }