Skip to content

Instantly share code, notes, and snippets.

@baiyanhuang
Created June 21, 2011 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baiyanhuang/1037579 to your computer and use it in GitHub Desktop.
Save baiyanhuang/1037579 to your computer and use it in GitHub Desktop.
# 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