#!/usr/bin/perl use warnings;; use strict; use threads; for (1..10) { print "hello $_ from main\n"; } for (1..10){ threads->create( \&thread, $_ )->detach; } print "all done, press the Enter key to exit\n"; <>; # this is done so the main thread dosn't exit before # the threads can finish sub thread { my $val = shift; foreach my $x (1..10) { print "hello $x from thread $val\n"; #select( undef,undef,undef,.5); #half second sleep } }