use threads; use threads::shared; my $thr=threads->create(\&serverRequest); use Tk; #bunch of stuff has to happen before the thread starts #running ... $thr->detach; while(flag that the thread is requesting){ &updateGUI; }