Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在java中,我们可以在同步方法中定义同步块吗?如果是这样,请举例说明
这是很有可能的:
public class Locker { private final Object lock = new Object(); synchronized void something() { synchronized (lock) { // tada } } }
但这是否有用是值得怀疑的。这感觉就像它大大增加了死锁的风险。