동기화(Synchronized) Collection

dykwon·2024년 1월 17일

동기화 Collection

  1. Vector와 Hashtable은 동기화 메소드로 구성되어있어서 멀티스레드 환경에서 안전하게 사용이 가능하다.

  2. 이외 Collection은 Collections.synchronizedXXX() 메소드를 통해 동기화 된 List, Map, Set으로 만들 수 있다.

List<String> synchronizedList = Collections.synchronizedList(new ArrayList<>());
Set<String> synchronizedSet = Collections.synchronizedSet(new HashSet<>());
Map<String, Integer> synchronizedMap = Collections.synchronizedMap(new HashMap<>());
profile
Programmer, who turns ideas into value

0개의 댓글