blob: 4476e463bd2f960c6475af6e2725d5737313b3dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
public class GetterLazyInAnonymousClass {
Object annonymous = new Object() {
class Inner {
private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> string = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
@java.lang.SuppressWarnings({"all", "unchecked"})
public String getString() {
java.lang.Object value = this.string.get();
if (value == null) {
synchronized (this.string) {
value = this.string.get();
if (value == null) {
final String actualValue = "test";
value = actualValue == null ? this.string : actualValue;
this.string.set(value);
}
}
}
return (String) (value == this.string ? null : value);
}
}
};
}
|