< prev index next >
src/java.base/share/classes/java/util/concurrent/locks/ReentrantLock.java
Print this page
8234131: Miscellaneous changes imported from jsr166 CVS 2021-01
Reviewed-by: martin
@@ -548,11 +548,11 @@
* not be entered with the lock already held then we can assert that
* fact:
*
* <pre> {@code
* class X {
- * ReentrantLock lock = new ReentrantLock();
+ * final ReentrantLock lock = new ReentrantLock();
* // ...
* public void m() {
* assert lock.getHoldCount() == 0;
* lock.lock();
* try {
@@ -578,11 +578,11 @@
* debugging and testing. For example, a method that should only be
* called while a lock is held can assert that this is the case:
*
* <pre> {@code
* class X {
- * ReentrantLock lock = new ReentrantLock();
+ * final ReentrantLock lock = new ReentrantLock();
* // ...
*
* public void m() {
* assert lock.isHeldByCurrentThread();
* // ... method body
@@ -592,11 +592,11 @@
* <p>It can also be used to ensure that a reentrant lock is used
* in a non-reentrant manner, for example:
*
* <pre> {@code
* class X {
- * ReentrantLock lock = new ReentrantLock();
+ * final ReentrantLock lock = new ReentrantLock();
* // ...
*
* public void m() {
* assert !lock.isHeldByCurrentThread();
* lock.lock();
< prev index next >