Lock锁
作者:互联网
ReentrantLock vs synchronized
- Lock显示锁; synchronized隐式锁
- lock只能锁代码块;synchronized可以锁代码块+方法锁
- Lock锁性能>synchronized
public class ReentrantLockTest { public static void main(String[] args) { Lock lock = new ReentrantLock(); try { lock.lock(); } finally { lock.unlock(); } } }
标签:synchronized,Lock,代码,ReentrantLock,lock,public 来源: https://www.cnblogs.com/jzbl/p/16388121.html