perl – 为什么要打印12次?
发布时间:2020-12-15 23:35:49 所属栏目:大数据 来源:网络整理
导读:我正在学习Perl的多线程.我的代码: use warnings;use threads;use threads::shared;$howmany = 10;$threads = 5;$to = int($howmany / $threads);for (0 .. $threads) {$trl[$_] = threads-create(main,$_);}for (@trl) {$_-join;}sub main { for (1 .. $t
我正在学习Perl的多线程.我的代码:
use warnings; use threads; use threads::shared; $howmany = 10; $threads = 5; $to = int($howmany / $threads); for (0 .. $threads) {$trl[$_] = threads->create(&;main,$_);} for (@trl) {$_->join;} sub main { for (1 .. $to) { print "testn"; } } exit(0); 我想在$threads线程中打印test $howmany这个词. 解决方法
然后我认为你想要(0 .. $threads-1)或(1 .. $线程),而不是(0 .. $线程)
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Delphi:如何摆脱“祖先的TMyForm找不到错误”?
- dcc32.exe命令行编译工程搜索路径的问题
- delphi学习 -----FormCreate,FormActivate,FormShow的顺序
- can't locate ExtUtils/MakeMaker.pm in @INC
- PAT 甲级 1086 Tree Traversals Again
- Delphi调试activex
- perl – WWW :: Mechanize :: Firefox xpath上一个结果
- 2011年6月编程语言排行榜,Lua进入前十
- lua -- 文件操作(I/O)
- BigInteger & BigDecimal