莊周夢蝶

          生活、程序、未來
             :: 首頁 ::  ::  :: 聚合  :: 管理

          保持java線程間可見性的5種方式

          Posted on 2008-02-23 10:44 dennis 閱讀(835) 評論(1)  編輯  收藏 所屬分類: java
          Primitive Writes up to and including… ...are made visible to…
          Object the end of a synchronized block or method a thread entering a synchronized block or method for the same object.
          Volatile field a write to a volatile field any thread reading that volatile field.
          Thread a call to Thread.start the newly started thread.
          Thread the final write made by a dying thread any thread which successfully calls Thread.join on that thread.
          Final field the initialization of a final field (but only those writes affecting the field and any object it references) any thread, provided that the constructor of the object containing the field doesn’t write the value of this anywhere eventually visible to other threads


            這些在《java并發編程實踐》一書中已經有詳細解釋,特別是對于ReentrantLock、volatile域以及final域的討論。今天在MenTaLguY的blog上看到這張表,摘錄下。

          評論

          # re: 保持java線程間可見性的5種方式  回復  更多評論   

          2008-02-23 16:08 by 魔域私服
          看不懂``````````
          主站蜘蛛池模板: 宾阳县| 宣威市| 富川| 大厂| 迭部县| 建阳市| 安达市| 南宁市| 本溪市| 丰顺县| 囊谦县| 辽源市| 古蔺县| 焉耆| 休宁县| 鲁甸县| 中宁县| 兰州市| 普兰县| 陆丰市| 龙南县| 贵溪市| 海城市| 成安县| 南开区| 汉中市| 孟州市| 临武县| 瑞昌市| 宁晋县| 渝北区| 揭阳市| 康保县| 遂溪县| 宁安市| 永宁县| 双鸭山市| 香港 | 铅山县| 儋州市| 交口县|