我想使用mod_perl线程,
以为例,我使用以下脚本:
use strict;
use warnings;
use threads;
sub doOperation{
my $vr = $_[0];
my $i = 0;
while($i < 10000000){
$i++
}
print "Thread done! var1 = $vrn";
threads->exit();
}
my @thr;
$thr[0] = threads->create(&doOperation,5);
$thr[1] = threads->create(&doOperation,6);
foreach(@thr){ $_->join(); }
I使用CLI可以正常工作:
# perl multithr.pl
Thread done! var1 = 6
Thread done! var1 = 5
但是如果通过Apache mod_perl模块运行,会导致Segmentation fault错误。
我环境:CentOS-6.5 x86_64
httpd-2.2.15
mod_perl-2.0.4
threads->exit();
此语句引发分段错误错误。正确退出线程!