112 |
|
* |
113 |
|
* <p>This class also provides convenience methods to {@link |
114 |
|
* #acquire(int) acquire} and {@link #release(int) release} multiple |
115 |
< |
* permits at a time. Beware of the increased risk of indefinite |
116 |
< |
* postponement when these methods are used without fairness set true. |
115 |
> |
* permits at a time. These methods are generally more efficient and |
116 |
> |
* effective than loops. However, they do not establish any preference |
117 |
> |
* order. For example, if thread A invokes @code{s.acquire(3}) and |
118 |
> |
* thread B invokes @code{s.acquire(2)}, and two permits become |
119 |
> |
* available, then there is no guarantee that thread B will obtain |
120 |
> |
* them unless its acquire came first and Semaphore @code{s} is in |
121 |
> |
* fair mode. |
122 |
|
* |
123 |
|
* <p>Memory consistency effects: Actions in a thread prior to calling |
124 |
|
* a "release" method such as {@code release()} |
416 |
|
* one of two things happens: |
417 |
|
* <ul> |
418 |
|
* <li>Some other thread invokes one of the {@link #release() release} |
419 |
< |
* methods for this semaphore, the current thread is next to be assigned |
419 |
> |
* methods for this semaphore, and the current thread is next to be assigned |
420 |
|
* permits and the number of available permits satisfies this request; or |
421 |
|
* <li>Some other thread {@linkplain Thread#interrupt interrupts} |
422 |
|
* the current thread. |
563 |
|
* |
564 |
|
* <p>Releases the given number of permits, increasing the number of |
565 |
|
* available permits by that amount. |
566 |
< |
* If any threads are trying to acquire permits, then one |
566 |
> |
* If any threads are trying to acquire permits, then one thread |
567 |
|
* is selected and given the permits that were just released. |
568 |
|
* If the number of available permits satisfies that thread's request |
569 |
|
* then that thread is (re)enabled for thread scheduling purposes; |