공부기록/기타

HashTable과 HashMap의 일반적인 차이

DGL 2021. 11. 23. 14:39

 

HashTable의 코드

    public synchronized int size() {
        return this.count;
    }

    public synchronized boolean isEmpty() {
        return this.count == 0;
    }

    public synchronized Enumeration<K> keys() {
        return this.getEnumeration(0);
    }

    public synchronized Enumeration<V> elements() {
        return this.getEnumeration(1);
    }

 

synchronized -> thread-safe

 

 

HashMap

synchronized를 사용하지 않음

 

싱글 스레드 환경에서 더 효율적