What is a Semaphore? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 153: What is a Semaphore?
Рекомендации по теме
Комментарии
Автор

A very important detail:

Semaphore allows unlocking (the #release() method) from any thread unlike traditional Locks that allows only owning threads to unlock.

That is applicable when you need to wake up a thread from another, an example — any consumer/supplier model.

_voidpointer
Автор

Most interesting topic in java and programming in general.

mmo
Автор

I wonder if semaphore.release() would be a good candidate to add to the try-with-resources feature. The feature could take either a Closable or a Releasable resource. Or do the use cases for semaphore.release() require more precision?

RickGladwin
Автор

If only English wasn't so simplistic as to call semaphores "traffic lights" but then we wouldn't have mid-stream pee sample, so we're even

ElficGuy
welcome to shbcf.ru