#!/usr/bin/perl -l use strict; use warnings; no warnings 'uninitialized'; use threads; use Time::Out qw(timeout); my (@t) = map( async( sub { my $tid = 'threads'->tid; my $worktime = shift @_; print "Thread $tid started with a worktime of $worktime"; eval { sub test { timeout 10, @_ => sub { print "$_[0]"; }; } }; print "Thread $tid ended ", $@ ? " with error: $@" : "normally"; }, 2 * $_ + $ARGV[0]), 1..4); $_->join foreach (@t);