As the question goes. I’m using the JDK 6.0 on Windows 7, and am attempting to use semaphores as a mechanism to solve a synchronization problem. It works perfectly, but I’m trying to avoid busy waiting in my problem.
I would just ask the java documentation and spare SO the trouble, but the docs go 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 to say, the docs seem to be implying both answers. Which one is correct?
It’s clearly wait/notify due to this line:
This means the thread is not scheduled by the OS until the event to wake it up (available semaphore permits) occurs, at which point the thread is signaled to continue execution.