mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
13 lines
345 B
Java
13 lines
345 B
Java
import javax.annotation.concurrent.GuardedBy;
|
|
|
|
class CheapReadWriteLock {
|
|
// Employs the cheap read-write lock trick
|
|
// All mutative operations MUST be done with the 'this' lock held
|
|
@GuardedBy("this") private volatile int value;
|
|
|
|
public int getValue() { return value; }
|
|
|
|
public synchronized int increment() {
|
|
return value++;
|
|
}
|
|
} |