«synchronize» 태그된 질문

8
동기화 된 (this)을 사용할 수 있다면 왜 ReentrantLock을 사용합니까?
동시성 잠금이 중요한 이유를 이해하려고합니다 synchronized (this). 아래의 더미 코드에서 다음 중 하나를 수행 할 수 있습니다. 전체 방법을 동기화하거나 취약한 영역을 동기화합니다 ( synchronized(this){...}) 또는 ReentrantLock으로 취약한 코드 영역을 잠그십시오. 암호: private final ReentrantLock lock = new ReentrantLock(); private static List<Integer> ints; public Integer getResult(String name) { . . …
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.