繁体   English   中英

在mod_perl中使用线程

[英]using threads in mod_perl

我想使用mod_perl的线程,

作为示例,我使用以下脚本:

use strict;
use warnings;
use threads;

sub doOperation{
        my $vr = $_[0];
        my $i = 0;
        while($i < 10000000){
                $i++
        }
        print "Thread done! var1 = $vr\n";
        threads->exit();
}

my @thr;
$thr[0] = threads->create(\&doOperation,5);
$thr[1] = threads->create(\&doOperation,6);

foreach(@thr){ $_->join(); }

我使用CLI顺利工作:

# perl multithr.pl
Thread done! var1 = 6
Thread done! var1 = 5

但是,如果通过Apache mod_perl模块运行它会导致分段错误。

我的环境:

CentOS-6.5 x86_64
httpd-2.2.15
mod_perl-2.0.4

threads->出口();

此语句引发了Segmentation fault错误。 正确退出线程!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM