<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    神奇好望角 The Magical Cape of Good Hope

    庸人不必自擾,智者何需千慮?
    posts - 26, comments - 50, trackbacks - 0, articles - 11
      BlogJava :: 首頁(yè) ::  :: 聯(lián)系 :: 聚合  :: 管理
    我對(duì) Java 關(guān)鍵字 Synchronized 的新理解 My New Understanding of Java's Synchronized Keyword
      說(shuō)實(shí)話,我對(duì) Java 并發(fā)編程知之不多。我曾經(jīng)常用關(guān)鍵字 volatile 試圖“強(qiáng)制原子操作”,結(jié)果帶來(lái)的麻煩比解決的還多。Sun Java 教程中的并發(fā)課程我以前從沒(méi)看完過(guò),現(xiàn)在該通讀一遍了。     To be honest, I knew only a little about concurrent programming in Java. I uesed to use keyword volatile as an attempt to "enforce atomic operations" which had brought me more troubles than solved. Time to walk through the Concurrency Trail of Sun's Java Tutorials that I never finished reading in the past.
      我其實(shí)知道并經(jīng)常看到關(guān)鍵字 synchronized 的使用,但直到昨天我還沒(méi)發(fā)覺(jué)就這個(gè)字消除了很多同步問(wèn)題。然而,真正的答案在我第一次看這個(gè)教程時(shí)就在里面了,到這次才弄清。     I do know and often see the usage of keyword synchronized, but until yesterday I hadn't figured out how thie single word elimated so many synchronization problems. However, the very answer lies in those tutorials ever since I first read it and this time it has been clearly understood.
      每個(gè)對(duì)象都關(guān)聯(lián)有一個(gè)內(nèi)部鎖,也被稱作監(jiān)視器鎖或簡(jiǎn)稱監(jiān)視器。當(dāng)一個(gè)線程調(diào)用一個(gè)同步方法時(shí),它自動(dòng)請(qǐng)求此方法的內(nèi)部鎖,并在方法返回時(shí)釋放。即使是未捕獲的異常造成了返回,也會(huì)發(fā)生鎖的釋放。而對(duì)靜態(tài)同步方法,方法所在類的 Class 對(duì)象的內(nèi)部鎖被請(qǐng)求。同步語(yǔ)句的內(nèi)部行為沒(méi)什么兩樣,只是還需要顯示指定一個(gè)需要請(qǐng)求其內(nèi)部鎖的任意對(duì)象。

        Every boject has an intrinsic lock, which is also known as monitor lock or monitor for short, associated with it. When a thread invokes a synchronized method, it automatically acquires the intrinsic lock for that method's object and releases it when the method returns. The lock release occurs even if the return was caused by an uncaught exception. As for a static synchronized method, an intrinsic lock for the Class object of that method's Class is acquired instead. Synchronized statements internally behaves no differently except in addition to this, an arbitrary object whose intrinsic lock will be acquired can be and should be explicitly specified.

      總之,synchronized 關(guān)鍵字是鎖定對(duì)象的簡(jiǎn)單方式,也有很多局限。java.util.concurrency.locks 包支持更高深的鎖定用法,也是我將要學(xué)的。

        In conclusion, synchronized keyword is a simplified way of locking objects, and also has many limitations. More sophisticated locking idioms are supported by the java.util.concurrency.locks package which I am going to learn.


    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 大学生一级特黄的免费大片视频| 免费一级毛片女人图片| 亚洲中文字幕久久精品无码VA| 午夜dj在线观看免费视频| 日韩在线观看免费| 亚洲日韩中文字幕天堂不卡| 又黄又大又爽免费视频| 在线观看肉片AV网站免费| 2020天堂在线亚洲精品专区| 亚洲国产婷婷香蕉久久久久久| 最近2019免费中文字幕视频三 | 亚洲另类图片另类电影| 免费亚洲视频在线观看| 99热精品在线免费观看| 精品久久久久久亚洲综合网| 久久久久久亚洲精品| 国产yw855.c免费视频| 99国产精品视频免费观看| 理论片在线观看免费| 亚洲视频一区在线观看| 亚洲人成无码www久久久| 18禁网站免费无遮挡无码中文| 国产成人无码免费看片软件 | 亚洲阿v天堂在线| 国产猛烈高潮尖叫视频免费 | 亚洲韩国精品无码一区二区三区| 久久久久国色AV免费观看性色| 中国一级毛片免费看视频| 亚洲日本中文字幕天天更新| 久久亚洲精品国产精品黑人| va亚洲va日韩不卡在线观看| 免费H网站在线观看的| 午夜无码A级毛片免费视频| 国产精品亚洲片在线花蝴蝶| 亚洲国产精品乱码在线观看97 | 亚洲欧美第一成人网站7777 | 免费无码又爽又刺激高潮| 99在线观看免费视频| 丝袜捆绑调教视频免费区| 亚洲av无码片vr一区二区三区| 亚洲另类视频在线观看|