首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

perl的线程(2)

作者:  时间: 2011-04-27

#!/usr/bin/perl
#
use threads;

sub say_hello {
  printf("Hello thread! @_.\n");
  sleep(10);
  printf("Bye\n");
}

 sub quick_exit {
printf("I will be exit in no time\n");
exit(1);
}

my $t1 = threads->create( \&say_hello, "param1", "param2" );
my $t2 = threads->create( {'exit'=>'thread_only'}, \&quick_exit );

$t1->join();
$t2->join();