兄弟帮我翻译一下,20分马上划拨!!!

whilliy 2004-07-05 10:21:35
lock Statement:
The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a statement, and then releasing the lock. This statement takes the following form:

lock(expression) statement_block
where:

expression
Specifies the object that you want to lock on. expression must be a reference type.
Typically, expression will either be this, if you want to protect an instance variable, or typeof(class), if you want to protect a static variable (or if the critical section occurs in a static method in the given class).

statement_block
The statements of the critical section.
Remarks
lock ensures that one thread does not enter a critical section while another thread is in the critical section of code. If another thread attempts to enter a locked code, it will wait (block) until the object is released.


...全文
105 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
whilliy 2004-07-11
  • 打赏
  • 举报
回复
不好意思晚来了几天!
北京的雾霾天 2004-07-08
  • 打赏
  • 举报
回复
莫非这一段我反的不对吗?
北京的雾霾天 2004-07-07
  • 打赏
  • 举报
回复
下面的标准的反译:

lock 语句
lock 关键字可将语句块标记为临界区,方法是获取给定对象的互斥锁,执行语句,然后释放该锁。此语句的形式如下:

lock(expression) statement_block
其中:

expression
指定要锁定的对象。expression 必须是引用类型。
通常,如果要保护实例变量,则 expression 为 this;如果要保护 static 变量(或者如果临界区出现在给定类的静态方法中),则 expression 为 typeOf (class)。

statement_block
临界区的语句。
备注
lock 确保当一个线程位于代码的临界区时,另一个线程不进入临界区。如果其他线程试图进入一个锁定代码,则它将在释放该对象前一直等待(块)。

buyifly 2004-07-06
  • 打赏
  • 举报
回复
锁陈述:
锁牛鼻子字藉由为一个给定的物体获得相互的- 排除锁为一个陈述区段作标记如一个紧要关头的区段,运行一份陈述, 然后释放锁。 这一份陈述采取下列各项形式:

锁 (表达) statement_block
哪里:

表达
叙述你锁定的物体。 表达一定是一个叁考类型。
典型地, 表达将会或是这,如果如果你保护一个静态的变数,你保护一个例证变数 , 或 typeof(班级) 。 (或如果紧要关头的区段在给定的班级一个静态的方法中发生)

statement_block
紧要关头的区段陈述。
评论
当另外的一条线是在密码的紧要关头的区段中的时候 , 锁确定一条线不进入一个紧要关头的区段。 如果另外的一条线尝试进入一个被锁的密码,它将会等候 (区段) 直到物体被释放。


金山快译翻的!!
roking 2004-07-05
  • 打赏
  • 举报
回复
文章是关于线程安全同步方面内容的。

111,119

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧