Immutable
2016-04-19 00:00
381 查看
摘要: 当数据不可以修改的时候,就没有数据同步的必要,自然就没有临界区了。
Immutable
Immutable pattern 也是多线程设计时候的一个准则,初学多线程把数据能准确分辨会变和不会变就可以前面两种模式混合使用,这个是一个比较基础,但却是十分重要的一个使用。
Immutable
Immutable pattern 也是多线程设计时候的一个准则,初学多线程把数据能准确分辨会变和不会变就可以前面两种模式混合使用,这个是一个比较基础,但却是十分重要的一个使用。
public class Main { public static void main(String args[]){ People people=new People("cdk","chengdu"); new PrintThread(people).start(); new PrintThread(people).start(); new PrintThread(people).start(); } } public final class People { private final String name; private final String address; public People(String name, String address) { this.name = name; this.address = address; } public String getName(){ return name; } public String getAddress(){ return address; } public String toString(){ return "[ person : name ="+name+" , address = "+address+" ]"; } } public class PrintThread extends Thread { private People people; public PrintThread(People people) { this.people=people; } public void run(){ while(true){ System.out.println(Thread.currentThread().getName()+" "+people); } } }
相关文章推荐
- Guarded Suspension
- balking
- PHP的微博微信QQ空间人人网分享的接口
- oracle使用过程遇到的小问题及解决方法
- reactiveCocoa
- swift和oc混编
- JS对cookie的操作方式
- httpSession 和 hibernate Session的区别
- nginx reload 命令报:nginx: [error] invalid PID number
- jQuery 追加元素方法
- junit4 单元测试
- uikeyboard所在uiwindow
- 怎么通过iMindMap的使用成为优秀的内容作家
- Effective C++: std::weak_ptr
- “师兄帮帮堂”正式成立
- 外循环与内循环的分析演示
- 堡垒机集中管控平台-麒麟开源堡垒机简介
- tar命令
- DIGITS的安装与使用记录
- rank() over,dense_rank() over,row_number() ove的区别