jython多线程 [英] jython multithreading

查看:130
本文介绍了jython多线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,我开始研究python,然后我找到了Jython.

I started studying python a couple of month ago, then I found Jython.

线程在Jython中正常工作,因为它没有GIL ?如果是这样,您能推荐一本关于并发(线程)的好书吗?

Do threads work properly in Jython, since it doesn't have a GIL? If so, can you suggest a good book on concurrency (threading)?

推荐答案

我在多线程方面遇到的最好的书是"Java Concurrency in Practice".它非常专注于Java线程并发性,当您开始理解并发性带来的问题和可能性时,既令人感到振奋又令人振奋.不过,我几年前购买的副本在编码中有一些勘误表,这加剧了本已具有大脑挑战性的主题:在此处查看勘误表: http://jcip.net/errata.html .

The best book I've encountered on multithreading is "Java Concurrency in Practice". It's very much concentrating on Java thread concurrency, and is both humbling and exciting when you start to understand the problems and the possibilities introduced by concurrency. The copy I bought a few years ago had some errata in the coding, though, which exacerbated an already brain-challenging subject: check out errata here: http://jcip.net/errata.html.

尽管是为希望冒险进行并发的Java开发人员设计的(顺便说一下,它包括曾经使用过任何GUI界面的任何人),但我确信本书中概述的技术难题和精妙之处适用于任何并发实现

Although designed for Java developers wishing to venture into concurrency (which by the way includes anyone who's ever used a GUI interface of any kind), I'm sure the technical difficulties and subtleties outlined in the book apply to any implementation of concurrency.

顺便说一句,我也喜欢Jython,并且可以确认在Java中可以并发执行的任何事情显然都可以在Jython中完成.但是,有一个警告:并发可以用于异步编程(包括GUI)和/或性能.如果对后者有问题,我认为:根据我的经验,Jython的运行速度比等效Java程序慢约10倍.

By the way, I also love Jython and can confirm that anything concurrency-wise that you can do in Java you can apparently do in Jython. However, there is a caveat: concurrency can be for asynchronous programming (including GUI) and/or for performance. If for the latter you have a problem, in my opinion: Jython in my experience runs about 10 x slower than the equivalent Java program.

这意味着您更苛刻的Jython模块将不得不调用除Jython之外的其他东西来进行数字运算.同时,到目前为止,Jython *还没有Python的多处理模块,因此除非您冒险进入RMI的可怕领域,否则进程间通信就不存在了.如果您选择该选项,那么您比我更是一个男人/女人.但是一切正常:请参阅 http://www.jython.org 上的"Jython权威指南". ..第19章介绍了并发性,第10章介绍了Java和Jython的集成(提示:这很简单).

What this means is that your more demanding Jython modules will have to call something other than Jython for the number-crunching tasks. At the same time, Jython up to now* has not had Python's multiprocessing module, so inter-process communications are out, unless you venture into the dreaded territory of RMI. You're more of a man/woman than I if you take that option. But everything's OK: please refer to "The Definitive Guide to Jython" at http://www.jython.org ... chapter 19 is a sort of whistle-stop intro to concurrency, and chapter 10 is about integrating Java and Jython (hint: it's absurdly easy).

  • 有趣:对Jython网站的快速浏览显示,就在10天前,2012年5月17日,发行了2.7a1版...是"Alpha"发行版.它应该包含Python 2.6附带的多处理模块. Wd对此进行了检查很有趣:如果是这样,大概可以给您提供链接Jython和CPython进程的激动人心的选项(稍后更新:遗憾的是,目前看来并非如此-我尝试时无法识别模块名称"multiprocessing" )...

最后说一句:对这些事情了解更多的专家,而不是我说摩尔定律已被阿姆达尔定律所取代,这简而言之意味着对稳定和可扩展的真正并发程序进行编程将面临艰巨的挑战.将来不可避免.我不能说使用聪明的代码分析工具可以使真正的(即线程)并发变得多么容易,但是对这一主题的投资以及由并发施加的引人入胜的,推理性的,知识性的新学科很可能会得到回报……如果你喜欢挑战.

PS a final word: most experts who know much more about these things than I say that Moore's law is being superseded in importtance by Amdahl's law, which in short means that the daunting challenge of programming stable and scalable true concurrent programs will be unavoidable in the future. Exactly how easy true (i.e. thread) concurrency can be made with the use of clever code analysis tools I can't say but investment in this subject and the fascinating, intellectual new disciplines of reasoning imposed by concurrency will probably pay off... if you like a challenge.

这篇关于jython多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆