Cracking the #Java #Coding #Interview - Question 153: What is a Semaphore? Watch all the questions here: • Cracking the Java Codi...
Пікірлер: 9
@_voidpointer544715 күн бұрын
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.
@brunocunha904315 күн бұрын
Very good point
@This.Object15 күн бұрын
Didn't get it man what was that again, if i acquire lock some other thread can release my lock? That I acquired?
@akalexus...15 күн бұрын
@@This.ObjectSemaphor isn't exclusive lock, it's blocking primitive used to limit access by counter.
@JosePaumard14 күн бұрын
Good point, thank you. Let me make another short on it 👍🏼
@m77mo6514 күн бұрын
Most interesting topic in java and programming in general.
@RickGladwin8 күн бұрын
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?
@ElficGuy14 күн бұрын
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