Perl 有哪些推荐的多线程管理器?
我对 Perl 中的多线程很陌生,正在寻找类似于 Java 线程池的东西。 有什么建议吗?
I'm new to multithreading in Perl and looking for something similar to Java's thread pools.
Any recommendations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您确实想要线程,请查看 threads.pm 和 threads::shared。
然而,Perl 没有像 Java 那样的轻量级线程,并且很少有人(相对)使用它们。许多“线程问题”可以通过基于事件的编程来解决(通常也更好)。
查找 AnyEvent 来查找:http://search.cpan.org/search?query=anyevent&mode=all
If you really want threads, then look at threads.pm and threads::shared.
However -- Perl doesn't have lightweight threads like Java and few people (relatively) use them. Many "thread problems" can be solved (often better, too) with event based programming.
Look for AnyEvent for that: http://search.cpan.org/search?query=anyevent&mode=all
使用线程;
使用threads::shared;
如果您对更透明的实现感兴趣,您还可以查看 subs::parallel 模块。
use threads;
use threads::shared;
You can also take a look at subs::parallel module if you're interested in more transparent implementation.
好吧,CPAN,其中包含 perl(ish) 的所有内容,有一个线程池实现,
Thread::Pool< /代码>
。还有另一种实现,但目前还不是生产代码。
Well CPAN, which contains all things perl(ish) has a thread pool implementation,
Thread::Pool
. There is another implementation, but it's currently not production code.