假设当前线程持有锁,那么同一个线程调用
synchronize(lock)
再说一遍,会发生死锁吗?
我依稀记得锁对于同一个线程是可重入的,什么意思?
最佳答案
来自documentation :
Thread cannot acquire a lock owned by another thread. But a thread can acquire a lock that it already owns. Allowing a thread to acquire the same lock more than once enables reentrant synchronization. This describes a situation where synchronized code, directly or indirectly, invokes a method that also contains synchronized code, and both sets of code use the same lock.
关于java - 以下情况会导致死锁吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10967866/