<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 :: 首頁 ::  :: 聯系 :: 聚合  :: 管理
    我對 Java 關鍵字 Synchronized 的新理解 My New Understanding of Java's Synchronized Keyword
      說實話,我對 Java 并發編程知之不多。我曾經常用關鍵字 volatile 試圖“強制原子操作”,結果帶來的麻煩比解決的還多。Sun Java 教程中的并發課程我以前從沒看完過,現在該通讀一遍了。     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.
      我其實知道并經常看到關鍵字 synchronized 的使用,但直到昨天我還沒發覺就這個字消除了很多同步問題。然而,真正的答案在我第一次看這個教程時就在里面了,到這次才弄清。     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.
      每個對象都關聯有一個內部鎖,也被稱作監視器鎖或簡稱監視器。當一個線程調用一個同步方法時,它自動請求此方法的內部鎖,并在方法返回時釋放。即使是未捕獲的異常造成了返回,也會發生鎖的釋放。而對靜態同步方法,方法所在類的 Class 對象的內部鎖被請求。同步語句的內部行為沒什么兩樣,只是還需要顯示指定一個需要請求其內部鎖的任意對象。

        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 關鍵字是鎖定對象的簡單方式,也有很多局限。java.util.concurrency.locks 包支持更高深的鎖定用法,也是我將要學的。

        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.


    只有注冊用戶登錄后才能發表評論。


    網站導航:
    博客園   IT新聞   Chat2DB   C++博客   博問  
     
    主站蜘蛛池模板: 67194成手机免费观看| 日韩亚洲国产高清免费视频| 在线A亚洲老鸭窝天堂| 内射无码专区久久亚洲| 国产美女精品视频免费观看| 成全影视免费观看大全二| 无码永久免费AV网站| 无码中文字幕av免费放| 我要看免费的毛片| 四虎影院免费在线播放| 免费理论片51人人看电影| 成人永久免费高清| 国产婷婷高清在线观看免费| 免费国产a国产片高清| 亚洲精品和日本精品| 久久精品亚洲福利| 国产l精品国产亚洲区在线观看| 久久久久久久亚洲精品| 国产亚洲色婷婷久久99精品| 久久精品国产亚洲av麻| 亚洲欧洲日产国产最新| 亚洲人成小说网站色| 国产精品亚洲专区无码唯爱网| 国产成人高清亚洲一区91| 未满十八私人高清免费影院| 国产一级在线免费观看| 99久久精品国产免费| 青青青免费国产在线视频小草| 毛片基地免费视频a| 全部免费国产潢色一级| 国产成人亚洲精品影院| 水蜜桃亚洲一二三四在线| 亚洲六月丁香六月婷婷蜜芽| 亚洲狠狠婷婷综合久久蜜芽| 成年网站免费入口在线观看 | 亚洲精品国产精品国自产观看 | 91大神免费观看| 免费爱爱的视频太爽了| 国产亚洲成归v人片在线观看| 久久99国产亚洲精品观看| 中文字幕无码精品亚洲资源网久久|