2017-03-13 Java多線程學(xué)習(xí)筆記-Doug Lea 談 Synchronization and the Java Memory Model

Doug Lea 談 Synchronization and the Java Memory Model

主要是討論同步和Java內(nèi)存模型之間的關(guān)系,講的原理,從多線程處理產(chǎn)生的問(wèn)題出發(fā),引導(dǎo)出同步的三個(gè)需要處理的問(wèn)題:原子性,可見(jiàn)性,順序性。

Atomicity

Which instructions must have indivisible effects. For purposes of the model, these rules need to be stated only for simple reads and writes of memory cells representing fields - instance and static variables, also including array elements, but not including local variables inside methods.

Visibility

Under what conditions the effects of one thread are visible to another. The effects of interest here are writes to fields, as seen via reads of those fields.

Ordering

Under what conditions the effects of operations can appear out of order to any given thread. The main ordering issues surround reads and writes associated with sequences of assignment statements.

講的特別棒,雖然英文吃力,但是有所得。

然后 Lea 還特別講了下 Java 關(guān)鍵字 Volatile,用到的場(chǎng)景:

The field need not obey any invariants with respect to others.
Writes to the field do not depend on its current value.
No thread ever writes an illegal value with respect to intended semantics.
The actions of readers do not depend on values of other non-volatile fields.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,011評(píng)論 0 23
  • Given a string, determine if it is a palindrome, consider...
    exialym閱讀 224評(píng)論 0 0
  • Whenever I encountered a grownup who seemed to me at all ...
    晨汐潮沙閱讀 742評(píng)論 0 0
  • 芳蘭獨(dú)影憐,花事已荼靡。 離離風(fēng)盈袖,脈脈雨隱溪。 美人芙蓉色,依稀殘夢(mèng)里。 終是落凡塵,歸去任東西。
    落梅君閱讀 349評(píng)論 0 2
  • 在黑夜里 伴隨著“咯噠”一聲 眼前的一切變的黑暗起來(lái) 恐懼并顫抖著身軀并大喊著 四處尋找著光線 哪怕只是一絲的亮光...
    脫度閱讀 279評(píng)論 0 0

友情鏈接更多精彩內(nèi)容