mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 00:17:45 +00:00
[review] [#3506] PR reviewed; passes review and passes tests.
This commit is contained in:
38 files changed
+406
-371
No files matched your search
@@ -1,8 +1,8 @@
|
||||
public class LockedExample {
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final ReentrantLock baseLock = new ReentrantLock();
|
||||
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final Lock baseLock = new ReentrantLock();
|
||||
private int value = 0;
|
||||
|
||||
|
||||
public int getValue() {
|
||||
this.lock.readLock().lock();
|
||||
try {
|
||||
@@ -11,7 +11,7 @@ public class LockedExample {
|
||||
this.lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setValue(int newValue) {
|
||||
this.lock.writeLock().lock();
|
||||
try {
|
||||
@@ -20,7 +20,7 @@ public class LockedExample {
|
||||
this.lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void foo() {
|
||||
this.baseLock.lock();
|
||||
try {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import lombok.experimental.Locked;
|
||||
import lombok.Locked;
|
||||
|
||||
public class LockedExample {
|
||||
private int value = 0;
|
||||
|
||||
|
||||
@Locked.Read
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
@Locked.Write
|
||||
public void setValue(int newValue) {
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
|
||||
@Locked("baseLock")
|
||||
public void foo() {
|
||||
System.out.println("bar");
|
||||
|
||||
Reference in new issue
Block a user