java 中的同步方法用作互斥量
synchronized method use as a mutex in java
我不懂一个简单的问题,
同步方法在java-
中用作mutex
什么
a) 全局声明的互斥量
b) 一个方法的互斥
c) 一个拥有对象的(这个)互斥量
任何人都可以详细说明一下吗?
提前致谢
选项c);来自 Goetz et al. (2006), Java Concurrency in Practice:
A synchronized
method is a shorthand for a synchronized
block that spans an entire method body, and whose lock is the object on which the method is being invoked. (Static synchronized
methods use the Class
object for the lock.)
我不懂一个简单的问题,
同步方法在java-
中用作mutex
什么
a) 全局声明的互斥量
b) 一个方法的互斥
c) 一个拥有对象的(这个)互斥量
任何人都可以详细说明一下吗? 提前致谢
选项c);来自 Goetz et al. (2006), Java Concurrency in Practice:
A
synchronized
method is a shorthand for asynchronized
block that spans an entire method body, and whose lock is the object on which the method is being invoked. (Staticsynchronized
methods use theClass
object for the lock.)