OWL ITS + 탐지시스템(인터넷 진흥원)
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
27
28
29
30
31
32
33
34
35
36
37
package kr.wisestone.owl.util;
 
/**
 * Created by wisestone on 2018-02-01.
 */
public class ThreadCounter {
    private volatile static ThreadCounter uniqueInstance;
 
    private ThreadCounter() {
    }
 
    public static ThreadCounter getInstance() {
        if (uniqueInstance == null) {
            synchronized (ThreadCounter.class) {
                if (uniqueInstance == null) {
                    uniqueInstance = new ThreadCounter();
                }
            }
        }
 
        return uniqueInstance;
    }
 
    private volatile Long count = 0L;
 
    public synchronized  Long getCount() {
        return count;
    }
 
    public synchronized  void setCount(Long count) {
        this.count = count;
    }
 
    public synchronized  void addCount() {
        this.count++;
    }
}