Do Java semaphores use wait or wait / notification by default?

Like a question. I am using JDK 6.0 on Windows 7 and trying to use semaphores as a mechanism to solve the synchronization problem. It works fine, but I try to avoid being busy with my problem.

I would just ask for java documentation and get rid of the problem, but the docs look like this:

Acquires the given number of permits from this semaphore,
 blocking until all are available, or the thread is interrupted.

Acquires the given number of permits, if they are available,
 and returns immediately, reducing the number of available permits
 by the given amount.

If insufficient permits are available then the current thread
 becomes disabled for thread scheduling purposes and lies dormant

http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Semaphore.html#acquire(int )

That is, the docs seem to imply both answers. Which one is correct?

+5
source share
2 answers

It explicitly expects / reports due to this line:

, .

, , ( ), .

0

, . , "" . , : , .

+1

All Articles