Difference [multithreading] synchronized with the Lock

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/wrs120/article/details/90717059

synchronized

  1. Keywords, based jvm
  2. Locks are released: @ 1: to acquire a lock thread executes the code block @ 2 over thread execution appear abnormal, is a passive way to release, () released by Monitor.exit, Monitor more explanation see:. HTTPS: // Blog. csdn.net/ignorewho/article/details/80854625
  3. It is a reentrant lock, interruptible lock,
  4. Suitable for less concurrency

Lock

  1. Interface, based on java programming
  2. Call Lock.unlock () to release the lock, is an active way to release
  3. Divided into: ReentrantLock read-write locks, ReadWriteLock reentrant lock, lock fair, interruptible lock
  4. Higher than the synchronized performance at high concurrency

Guess you like

Origin blog.csdn.net/wrs120/article/details/90717059