作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在以下脚本中:
use strict;
use warnings;
use LWP::Simple;
use threads;
threads->create(sub {
my $url = "http://www.example.com/logo.jpg";
my $file = "/var/www/html/logo.jpg";
getstore($url, $file);
threads->detach();
});
最佳答案
因为“分离”并没有达到您的期望。当程序退出时,分离的线程将终止。 From the docs...
$thr->detach()
Makes the thread unjoinable, and causes any eventual return value to be discarded. When the program exits, any detached threads that are still running are silently terminated.
Perl exited with active threads:
1 running and unjoined
0 finished and unjoined
0 running and detached
而不是分离,您应该等到程序结束时所有线程都完成。
for my $thread (threads->list(threads::running)) {
$thread->join;
}
关于multithreading - Perl getstore在线程中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41758080/
我是一名优秀的程序员,十分优秀!