-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSampleRunner.java
More file actions
26 lines (22 loc) ยท 900 Bytes
/
Copy pathSampleRunner.java
File metadata and controls
26 lines (22 loc) ยท 900 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
26
package Chapter2.Day8;
public class SampleRunner {
/**
* GC ๊ฐ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํด์ ํด์ฃผ๊ธด ํ์ง๋ง, ์ธ์ ํธ์ถ๋ ์ง ๋ชจ๋ฅด๊ธฐ์,
* ์ฌ์ฉ์ด ๋๋๊ณ Finalizer ์ ๋ช
์์ ์ผ๋ก ํธ์ถํ ์ ๊ฐ ์๋ค. ํ์ง๋ง ์ด๋ ์ข์ง ์๋ค.
*
* Finalizer ์กฐ์ฐจ ์ธ์ ํธ์ถ๋ ์ง ๋ชจ๋ฅด๊ธฐ ๋๋ฌธ์ด๋ค.
*
* ๋ฐ๋ผ์ ์์ ๋ฐ๋ฉ์์๋ try-with-resource ๋ฅผ ์ฌ์ฉํ๊ฑฐ๋
*/
public static void main(String[] args) throws InterruptedException {
SampleRunner runner = new SampleRunner();
runner.run();
// GC ๋ ์ธ์ ์คํ๋ ์ง ๋ชจ๋ฅด๋๊น System.gc() ์ ์์กดํ๋ฉด ์
System.gc();
// Thread.sleep(1000l); // ์ด๊ฑฐ ํด๋ Finalizer ํธ์ถ ์๋ฌ์
}
private void run() {
FinalizerExample finalizerExample = new FinalizerExample();
finalizerExample.hello();
}
}