-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix issue #482: 优化并发章节翻译 #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -247,7 +247,7 @@ C语言是面向过程语言,这限制了它的野心。这些限制使附加 | |||
|
|||
Java实验告诉我们,结果是悄然灾难性的。程序员很容易陷入认为Java 线程并不那么困难的陷阱。似乎工作的程序充满了微妙的并发bug。 | |||
|
|||
为了获得正确的并发性,语言功能必须从头开始设计并考虑并发性。这艘船航行了;Java将不再是为并发而设计的语言,而只是一种允许它的语言。 | |||
为了获得正确的并发性,语言功能必须从头开始设计并考虑并发性。这艘船航行了;Java将不再是为并发而设计的语言,而只是一种允许它的语言。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这句话很奇怪。完全读不通。
贴原文上来一起看看吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get concurrency right, language features must be designed from the
ground up with concurrency in mind. That ship has sailed; Java will
never be a language designed for concurrency, but simply a language
that allows it. 是这艘船。。这句话吗?大概意思就是回不了头了吧。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「航行了」总还是觉得怪怪的,还有后面的代词其实读起来也不是很顺口。
咱们改成这样吧
这艘船起航了;Java 将不再是为并发而设计的语言,而只是一种允许并发的语言。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
木已成舟怎么样?虽然这样已经和原文不同,但是意思我觉得可以传达得很清楚
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我觉得可以
@@ -701,7 +704,7 @@ current是使用线程安全的 **AtomicInteger** 类定义的,可以防止竞 | |||
|
|||
这个块大小似乎是内部实现的一部分(尝试使用**limit()**的不同参数来查看不同的块大小)。将**parallel()**与**limit()**结合使用可以预取一串值,作为流输出。 | |||
|
|||
试着想象一下这里发生了什么:一个流抽象出无限序列,按需生成。当你要求它并行产生流时,你要求所有这些线程尽可能地调用get()。添加limit(),你说“只需要这些。”基本上,当你将parallel()与limit()结合使用时,你要求随机输出 - 这可能对你正在解决的问题很好。但是当你这样做时,你必须明白。这是一个仅限专家的功能,而不是要争辩说“Java弄错了”。 | |||
试着想象一下这里发生了什么:一个流抽象出无限序列,按需生成。当你要求它并行产生流时,你要求所有这些线程尽可能地调用get()。添加limit(),你说“只需要这些。”基本上,当你将parallel()与limit()结合使用时,你要求随机输出 - 这可能对你正在解决的问题有效。但是当你这样做时,你必须明白。这是一个仅限专家的功能,而不是要争辩说“Java弄错了”。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个语序也奇怪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原文:Basically, you’re asking for random output when you combine parallel() with limit()—which might be just fine for
the problem you’re solving. 改成:基本上,当你为了随机输出而选择将parallel()与limit()结合使用时,这种方法可能对你正在解决的问题有效。 如何?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改进之后比之前好了
@@ -291,7 +291,7 @@ Java 8 CompletableFuture是一个更好的解决方案:它允许你将操作 | |||
<!-- Parallel Streams --> | |||
## 并行流 | |||
|
|||
Java 8流的一个显着优点是,在某些情况下,它们可以很容易地并行化。这来自仔细的库设计,特别是流使用内部迭代的方式 - 也就是说,它们控制着自己的迭代器。特别是,他们使用一种特殊的迭代器,称为Spliterator,它被限制为易于自动分割。这产生了相当神奇的结果,即能够简单用parallel()然后流中的所有内容都作为一组并行任务运行。如果你的代码是使用Streams编写的,那么并行化以提高速度似乎是一种琐事 | |||
Java 8流的一个显著优点是,在某些情况下,它们可以很容易地并行化。这来自设计库时的仔细,特别是流使用内部迭代的方式 - 也就是说,它们控制着自己的迭代器。特别是,他们使用一种特殊的迭代器,称为Spliterator,它被限制为易于自动分割。这会产生像魔法一样的结果,我们只需念**.parallel()**,然后流中的所有内容都作为一组并行任务运行。如果你的代码是使用Streams编写的,那么并行化以提高速度似乎是一种琐事 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这来自设计库时的仔细
你这个翻译改顺序之后更起卦了。。
们只需念**.parallel()** 原文贴出来一起看下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces the rather magical result of being able to simply say .parallel() and suddenly everything in your stream is
running as a set of parallel tasks. 我翻译成念只是为了更符合咒语的表述。。 “来自设计库时的仔细”确实有点怪。。我再改回去吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces the rather magical result of being able to simply say
of 后面的是原因,这个应该把语序提前。
我们只需要念 .parallel() 就会产生魔法般的结果,流中的所有内容都作为一组并行任务运行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以
- 链接列表没有这些属性;“拆分”一个链表仅仅意味着把它分成“第一元素”和“其余列表”,这相对无用。 | ||
- 无状态生成器的行为类似于数组;使用上述范围是无可争议的。 | ||
- 数组分割成本低,分割均匀且对分割的大小有着完美的掌控。 | ||
- 链表没有这些属性;“拆分”一个链表仅仅意味着把它分成“第一元素”和“其余元素”,这相对无用。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个分号原文也是用的英文字符吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,是
No description provided.