foreach $lpar ( @lparList ) { threads->create( sub { threads->yield(); manageLPAR ($action,$lpar); } )->detach; } sleep $timeout; ## fall of the end of the script ## the detach threads will end when the main thread does.