Created
June 21, 2011 10:27
-
-
Save baiyanhuang/1037579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sleep sort!!! | |
use strict; | |
use Thread; | |
my @threads; | |
my $count = 0; | |
foreach my $n (@ARGV) { | |
next unless defined $n; | |
$threads[$count] = Thread->new(\&start_thread, $n); | |
$count++; | |
} | |
foreach my $thread (@threads) { | |
$thread->join(); | |
} | |
print "\nsleep sort done!"; | |
############################################# | |
sub start_thread{ | |
my ($num) = @_; | |
sleep $num; | |
print $num; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment