庄周梦蝶

生活、程序、未来
   :: 首页 ::  ::  :: 聚合  :: 管理

保持java线程间可见性的5种方式

Posted on 2008-02-23 10:44 dennis 阅读(829) 评论(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 魔域私服
看不懂``````````

只有注册用户登录后才能发表评论。


网站导航: