MCPcopy Index your code
hub / github.com/BruceEckel/OnJava8-Examples / IntegerSingleton

Class IntegerSingleton

patterns/SingletonPattern.java:6–21  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4// Visit http://OnJava8.com for more book information.
5
6final class IntegerSingleton
7 implements Resource<Integer> {
8 private static IntegerSingleton value =
9 new IntegerSingleton();
10 private Integer i = Integer.valueOf(0);
11 private IntegerSingleton() {
12 System.out.println("IntegerSingleton()");
13 }
14 public static IntegerSingleton instance() {
15 return value;
16 }
17 @Override public synchronized
18 Integer get() { return i; }
19 @Override public synchronized
20 void set(Integer x) { i = x; }
21}
22
23public class SingletonPattern {
24 public static <T> void show(Resource<T> r) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected