forked from hazukac/DesignPatterns
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.java
More file actions
25 lines (22 loc) · 807 Bytes
/
Main.java
File metadata and controls
25 lines (22 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// importするパッケージをさきにコンパイルするひつようがある
import mysingleton.*;
import java.util.Date;
public class Main {
public static void main (String[] args) {
Date now = new Date();
System.out.println(now);
// 単一のリソースだったり
// リソース管理する単一の入り口だったり
Singleton theInstance;
theInstance = Singleton.getInstance();
System.out.println(theInstance.initializedAt);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// e
}
Singleton anotherInstance = Singleton.getInstance();
// anotherInstance = new Singleton("piyopiyo");
System.out.println(anotherInstance.initializedAt);
}
}