Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading Can';t调用方法";GetChildrenByTagNames“;关于无版权引用?_Multithreading_Perl - Fatal编程技术网

Multithreading Can';t调用方法";GetChildrenByTagNames“;关于无版权引用?

Multithreading Can';t调用方法";GetChildrenByTagNames“;关于无版权引用?,multithreading,perl,Multithreading,Perl,我是新手,我就是这么做的: my $thread_fifo = threads->create(sub {Plugins::Fifo->run($conf, $products, $workfifo)}); my $thread_liberty = threads->create(sub {Plugins::Fifo->run($conf, $products, $workliberty)}); 然后:$thread\u fifo->join()$thread_libe

我是新手,我就是这么做的:

my $thread_fifo = threads->create(sub {Plugins::Fifo->run($conf, $products, $workfifo)});
my $thread_liberty = threads->create(sub {Plugins::Fifo->run($conf, $products, $workliberty)});
然后:
$thread\u fifo->join()$thread_liberty->join()

以下是错误消息:

Thread 1 terminated abnormally: Can't call method "getChildrenByTagNameNS" on unblessed reference at C:/strawberry/perl/site/lib/XML/Atom/Util.pm line 61.
要查看什么是
$thread\u fifo
,我使用ref和Dumper:

print ref($thread_fifo);#输出:线程

打印转储程序($thread\u fifo)#输出:$VAR1=bless(do{\(my$o='78589096'),'threads')

我知道一个非lessed引用错误是一个变量不是对一个对象的合法引用,但却试图像调用合法对象一样调用它的函数,但是我不知道这里的问题出在哪里,我所要做的就是同时调用两个函数


提前感谢。

这不是一个完整的解决方案,但应该足以看到发生了什么

threads->create(\&foobar,$products,$workfifo,'info');
threads->create(\&foobar,$products,$workliberty,'liberty');

# Master Thread
my @threads = threads->list();
for(my $i=0; $i<scalar(@threads); ++$i) {
  print STDERR "MASTER: about to join thread $i\n";
  my $thread = $threads[$i];
  eval {
    $thread->join();
  };
  if($@) {
    print STDERR "Caught error while joining thread $i ($@)\n";
  }
  else {
    print STDERR "MASTER: finished joining thread $i\n";
  }
}
@threads = threads->list();
print STDERR "I GOT " . scalar(@threads) . ", NOW EXITING\n";
exit;

# Child threads
sub foobar {
  my ($products,$work,$str) = @_;
  print STDERR "CHILD $str: STARTING\n";
  Plugins::Fifo->run($conf, $products, $work);
  print STDERR "CHILD $str: ENDING\n";
}
threads->create(\&foobar,$products,$workfifo,'info');
线程->创建(\&foobar,$products,$workliberty,'liberty');
#主线程
我的@threads=threads->list();
对于(my$i=0;$ijoin();
};
如果($@){
print STDERR“加入线程$i($@)时捕获错误\n”;
}
否则{
打印STDERR“主线程:已完成连接线程$i\n”;
}
}
@线程=线程->列表();
打印STDERR“I get”.scalar(@threads)。”,现在退出\n;
出口
#子线程
子foobar{
我的($products,$work,$str)=@;
打印STDERR“CHILD$str:STARTING\n”;
插件::Fifo->run($conf,$products,$work);
打印STDERR“CHILD$str:ENDING\n”;
}

您甚至没有显示调用
getChildrenByTagnames
?!在我的代码中没有
getChildrenByTagnames
,在
C:/草莓/perl/site/lib/XML/Atom/Util.pm
I get
无法调用方法“join”中可以看到错误消息在…
的一个未定义的值上,我添加了一点调试,您能告诉我您的(1)use语句位于您的文件上吗(2)运行此命令的输出&(3)您的2个join语句中的哪一个导致了错误?谢谢。