linux - Perl 以事件线程 : 退出

标签 linux multithreading perl

我有一个 Perl 程序。一切正常,但我看到以下错误。我最后也加入了线程,并尝试检查 is_joinable,但没有任何效果。这个错误目前没有引起任何问题,但我想修复它

Perl exited with active threads:
        6 running and unjoined
        0 finished and unjoined
        0 running and detached

代码

my @threads;
open FILE, "$inputCsv" or die $!;
my @records = <FILE>;

foreach $record ( @records ) {
    @fields = split( /,/, $record );
    $identityDomain = $fields[0];
    push( @threads, threads->new( \&populateSubscriptionMap, $identityDomain ) );
}

foreach $thr ( @threads ) {
    print "threads - " . $thr;
    my %myhash = $thr->join();
}

我在这上面花了将近 3 个小时,并尝试了各种方法。如果有人可以看看并帮助我,我将不胜感激。

最佳答案

$_->join() for threads->list();

是一种等待所有线程结束的简单方法,但您的问题更有可能是您实际上没有到达获取线程的代码部分。最可能的罪魁祸首是:

  • 您的主线程抛出了一个未捕获的异常。
  • 您的主线程或其他线程之一使用了exit

关于linux - Perl 以事件线程 : 退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34100252/

相关文章:

perl - 为 perl 脚本添加并行性

linux - syscall(2) 是标准的一部分吗?

linux - 通过 ssh 发送 tee 命令

Perl,LWP "certificate verify failed"与 paypal.com

windows - WaitForSingleObject 是否放弃线程的时间片?

ios - GCD 错误 :Tried to obtain the web lock from a thread other than the main thread or the web thread

perl - ERR 错误编译脚本(新函数): user_script:2: '=' expected near 'end' , .../lib/site_perl/5.8.7/Redis.pm 第 163 行

linux - iwconfig 在哪里获取有关 linux 比特率的数据

c - Linux 中断与轮询

java - 为什么我们在这里特别说 ArrayList 不是线程安全的?