본문 바로가기

공부기록/기타

HashTable과 HashMap의 일반적인 차이

 

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를 사용하지 않음

 

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

'공부기록 > 기타' 카테고리의 다른 글

[git] merge vs rebase  (0) 2021.12.29
http 0.9~ 3  (0) 2021.12.24
reverse proxy  (0) 2021.12.23
block, non-block / sync, async  (0) 2021.12.22
webRTC 개념이해  (0) 2021.12.22