What happens when a thread cannot acquire a Semaphore (due to lack of permit). Will it be moved to the wait state?
EDIT:Will the thread start resume the previous execution sequence, when the semaphore becomes available.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. If you’re talking about
java.util.concurrent.Semaphore(and theaquiremethod this is what happens:tryAquirewill however, as the name suggests, only try to aquire the lock, and instead of blocking return false if it has no permit.Yes. If another thread calls
releasethis thread may return fromacquireand continue it’s execution.