mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 06:17:44 +00:00
[docs] Locked example needed its usage examples moved
This commit is contained in:
2 files changed
No files matched your search
@@ -1,32 +0,0 @@
|
||||
public class LockedExample {
|
||||
private final ReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final Lock baseLock = new ReentrantLock();
|
||||
private int value = 0;
|
||||
|
||||
public int getValue() {
|
||||
this.lock.readLock().lock();
|
||||
try {
|
||||
return value;
|
||||
} finally {
|
||||
this.lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(int newValue) {
|
||||
this.lock.writeLock().lock();
|
||||
try {
|
||||
value = newValue;
|
||||
} finally {
|
||||
this.lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void foo() {
|
||||
this.baseLock.lock();
|
||||
try {
|
||||
System.out.println("bar");
|
||||
} finally {
|
||||
this.baseLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
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