8186056: Miscellaneous changes imported from jsr166 CVS 2017-09

Reviewed-by: martin, psandoz
This commit is contained in:
Doug Lea 2017-10-03 14:00:00 -07:00
parent 229cce5f44
commit c3664b7f38
16 changed files with 193 additions and 135 deletions

View file

@ -73,7 +73,7 @@ import java.util.concurrent.TimeUnit;
* available in the buffer. This can be achieved using two
* {@link Condition} instances.
* <pre>
* class BoundedBuffer {
* class BoundedBuffer&lt;E&gt; {
* <b>final Lock lock = new ReentrantLock();</b>
* final Condition notFull = <b>lock.newCondition(); </b>
* final Condition notEmpty = <b>lock.newCondition(); </b>
@ -81,7 +81,7 @@ import java.util.concurrent.TimeUnit;
* final Object[] items = new Object[100];
* int putptr, takeptr, count;
*
* public void put(Object x) throws InterruptedException {
* public void put(E x) throws InterruptedException {
* <b>lock.lock();
* try {</b>
* while (count == items.length)
@ -95,12 +95,12 @@ import java.util.concurrent.TimeUnit;
* }</b>
* }
*
* public Object take() throws InterruptedException {
* public E take() throws InterruptedException {
* <b>lock.lock();
* try {</b>
* while (count == 0)
* <b>notEmpty.await();</b>
* Object x = items[takeptr];
* E x = (E) items[takeptr];
* if (++takeptr == items.length) takeptr = 0;
* --count;
* <b>notFull.signal();</b>
@ -310,7 +310,8 @@ public interface Condition {
* the following form:
*
* <pre> {@code
* boolean aMethod(long timeout, TimeUnit unit) {
* boolean aMethod(long timeout, TimeUnit unit)
* throws InterruptedException {
* long nanos = unit.toNanos(timeout);
* lock.lock();
* try {
@ -320,6 +321,7 @@ public interface Condition {
* nanos = theCondition.awaitNanos(nanos);
* }
* // ...
* return true;
* } finally {
* lock.unlock();
* }
@ -410,7 +412,8 @@ public interface Condition {
* <p>The return value indicates whether the deadline has elapsed,
* which can be used as follows:
* <pre> {@code
* boolean aMethod(Date deadline) {
* boolean aMethod(Date deadline)
* throws InterruptedException {
* boolean stillWaiting = true;
* lock.lock();
* try {
@ -420,6 +423,7 @@ public interface Condition {
* stillWaiting = theCondition.awaitUntil(deadline);
* }
* // ...
* return true;
* } finally {
* lock.unlock();
* }