Synchronized Vs Semaphore

前端 未结 3 679
[愿得一人]
[愿得一人] 2021-02-07 01:18

While reading concurrency in Java, I have following doubts:

  1. Does Java provides lower level construct then synchronized for synchronization?

  2. In

3条回答
  •  无人及你
    2021-02-07 01:35

    Synchronized allows only one thread of execution to access the resource at the same time. Semaphore allows up to n (you get to choose n) threads of execution to access the resource at the same time.

提交回复
热议问题