What is mutex and semaphore in Java ? What is the main difference?

前端 未结 11 1581
梦毁少年i
梦毁少年i 2020-11-27 09:28

What is mutex and semaphore in Java ? What is the main difference ?

11条回答
  •  时光说笑
    2020-11-27 09:50

    A mutex is used for serial access to a resource while a semaphore limits access to a resource up to a set number. You can think of a mutex as a semaphore with an access count of 1. Whatever you set your semaphore count to, that may threads can access the resource before the resource is blocked.

提交回复
热议问题