计算机文章翻译(英译汉)第一部分

来源:百度知道 编辑:UC知道 时间:2024/06/08 06:50:39
CRITICAL SECTION

DESCRIPTION
A Critical Section is a segment of code that must be executed by only one thread
at a time to produce the expected results. When more than one thread is allowed
to execute this code segment, it could produce unpredictable results. By this
definition, a critical section looks very similar to the concept of a Monitor discussed in Section III — Basic Patterns. The following is the list of similarities and differences between Monitors and Critical Sections:
•A Critical Section is a stricter form of a Monitor.
•A Monitor locks a single object whereas a Critical Section requires a lock
on an entire class of objects.
•In Java:
– The implementation of a Monitor on a method requires the method to
be declared using the synchronized keyword.
– A Critical Section can be implemented by using the combination of both
t he static and the synchronized keywords.
•In the case o

保证人译,绝非机译

临界区

描述
临界区是一个段的代码,它必须仅被一个线程在一个时间执行来产生预期的结果。当多个线程被允许执行此代码段时,它可以产生无法预测的结果。根据这一定义,一个临界区看起来与我们在第三节-“基本模式”中讨论过的监视器的概念非常相似。以下是监视器和临界区的异同列表:
•临界区是一个比监视器更严格的形式。
•监视器锁定一个信号对象,而临界区需要锁定一个整类的对象。
•在Java方面 :
-监视器对一项方法的执行需要该方法已声明使用同步关键字。
-临界区可以用静态和同步关键字两者结合的方式来实现。
•就显示器而言,没有任何两个线程被允许对相同的对象执行同步代码。两个线程可以对两个不同的对象执行相同的同步代码。与此相反,就临界区而言,没有任何两个线程被允许对两个不同对象执行不同代码。这是因为代码已被锁定在类水平,而不是在对象水平。

可能不够十分准确, 见谅

A Critical Section is a segment of code that must be executed by only one thread at a time to produce the expected results. When more than one thread is allowed to execute this code segment, it could produce unpredictable results. By this definition, a critical section looks very similar to the concept of a Monitor discussed in Section III — Basic Patterns.
一个临界区是一段代码每次必须只执行一次线程以得到预期的结果。当多个线程去执行该段代码时,结果可能会有不可预知性。通过定义,一个临界区看上去与第三章基本模式所讨论的监听的概念非常类似。

The following is the list of simila