자바 Multi Thread 환경에서 동시성 제어
##스레드란
##스레드 안정성이 깨지는 상황
public class CountingTest { public static void main(String[] args) { Count count = new Count(); for (int i = 0; i < 100; i++) { new Thread(){ public void run(){ for (int j = 0; j < 100; j++) { System.out.println(count.view()); } } }.start(); } } } class Count { private int count; public int view() {return count++;} public int getCount() {return count;} }

##동시성을 제어하는 방법 : Lock

#언제 synchoronized 식별자 사용?
##동시성을 제어하는 방법 : Volatile
#사용상황
#Java volatile가 필요한 이유?

#Example

#해결방법
#volatile 성능
#정리
##동시성을 제어하는 방법 : Atomic
#AtomicInteger 메서드
#example
#CAS(Compare And Swap)알고리즘

##synchronized, volatile, AtomicInteger 비교
##스레드 안전한 객체 사용
#Concurrent 패키지
Last updated