惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 叶小钗
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 聂微东
M
MIT News - Artificial intelligence
F
Fortinet All Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
T
Tailwind CSS Blog
Recent Announcements
Recent Announcements
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks

博客园 - Colin_Ye

Mac OS X 中 emacs 24.x+clojure+lein2.x+slime简单编程环境的搭建 JDK中可扩展性和线程安全的注意事项 并发中状态的处理 并发的任务分工 语言分类,我接触和我想学习的 CPU的内部物理结构介绍【转】自己留着看看 提高编程技巧的十大方法 关于大型机的入门介绍【转】 什么是S-OFF【转】 Android 常识【转·】 关于APK、ROM、SPL、Superuser、ROOT、recovery【转】此文有很多不当之处,但还可以看看 关于Bootloader、Recovery 比较全的Linux目录存放内容 tomcat 内存问题 部分银行核心系统的资料 【转】 一些软件设计的原则【转】——本来想自己总结,结果发现个更全的, 公私钥与加密、签名 SOA复习与总结——企业应用系统集成的总结(1)——基本原则和术语介绍 重读模式与架构(2)——层次划分的依据和角色职责
JDK中并发状态管理注意事项
Colin_Ye · 2012-02-24 · via 博客园 - Colin_Ye

Working with shared mutable state is a huge burden that requires us to

endure added complexity and the accompanied greater chances of error.

When refactoring code, look out for some common concurrency-related

mistakes:

• Don’t create threads from within constructors; instead, create them in static factory methods

• Don’t create arbitrary threads; instead, use a pool of threads to reduce the tasks startup time and resource use.

• Ensure that access to mutable fields cross memory barrier and are visible to threads properly.

•Evaluate the granularity of locks and promote concurrency. Ensure that the locks are not overly conservative but are at the right level to provide adequate thread safety and concurrency at the same time.

• When working with multiple mutable fields, verify that the access to these variables is atomic; that is, other threads don’t see partial changes to these fields.