gat*_*eta 1 perl multithreading glob
以下脚本在perl 5.16中崩溃.glob()在线程中使用有什么问题吗?
use strict;
use warnings;
use 5.010;
use threads;
sub f {
my $no = shift;
my @arr = glob("*");
say "thread $no: ", scalar(@arr);
}
foreach my $tno (1..5) {
my $thr = threads->create(\&f, $tno);
$thr->join();
}
Run Code Online (Sandbox Code Playgroud)
它打印
thread 1: 33
Run Code Online (Sandbox Code Playgroud)
然后崩溃与分段错误(MacOS)或访问冲突(Windows 7).用v5.16.2 on Mac OSX (darwin-thread-multi-2level)和测试ActivePerl on Windows 7 64bit (v5.16.3 built for MSWin32-x86-multi-thread).
| 归档时间: |
|
| 查看次数: |
163 次 |
| 最近记录: |