Lock on Static and non-static Methods
来源:互联网 发布:淘宝投诉商家怎么投诉 编辑:程序博客网 时间:2024/04/30 15:48
问题
Synchronized 关键字分别用在静态和非静态函数上,
其他setting相同, 多线程各自调用1000次, 哪个更快些?
http://stackoverflow.com/questions/5654654/static-synchronized-
http://stackoverflow.com/questions/18356795/static-versus-non-s
从这两个连接里看
貌似non static的快些,因为如果不同的obj,会不同的锁,互相不影响;
而static的,即使是不同的obj,因为锁是在class上,所以会互相block。
看锁所处对象所在的位置
static在method里面
一般obj在heap里面
方法区的操作会比heap里慢一些
所以heap会慢一点
但是如果不是操作同一个对象的话
显然heap的快,因为没有并发冲突的问题
这题要确认一下对象本身是否是singleton
0 0
- Lock on Static and non-static Methods
- Static Methods, Class Methods, and Decorators
- 17.5.2 Static and instance methods
- 17.5.2 Static and instance methods
- The Default Methods And Static Methods In Java Interface
- Static与non Static
- Mocking static methods (PowerMock )
- Static/Class methods
- Static methods 静态方法
- Java – Static Class, Block, Methods and Variables
- non-static inner class
- non-static method
- django static Cannot mix str and non-str arguments
- factory | factory methods | static factory methods
- jetty static file lock
- static与non-static的区别
- static与non-static的区别
- local static与non local static
- isdigit()极品实现
- js prototype 用法 需与 jQuery extend 方法一起看
- 泛型算法
- ubuntu12.04 重启,日志记录EXT4-fs: re-mounted Opts: errors=remount-ro解决方法
- 银行涉足电商收入颇丰
- Lock on Static and non-static Methods
- C++学习笔记2:数组与容器,指针与迭代器
- WCF之初体验
- 让我如何相信你,电商的打折
- 百货的客单价-林财添
- setuid()与setgid() -- 设置 UID 和 GID
- 求直线终点公式(起点,方向向量,距离)
- 句法模式识别(一)-串文法
- 引用ASIHttprequest的时候 遇到的问题