동기화 (1) 썸네일형 리스트형 JAVA Thread 동기화 방법 Java에서 Thread를 동기화 하는 방법. synchronized를 사용하면 된다. 아래 코드를 참조. class A extends Thread { private int value = 0; public synchronized void setValue(int var) { value = var; } public void run() { //synchronized로 block된 부분은 동기화처리가 된다. synchronized (this) { //처리할 코드 } } } public class Test { public station void main(String[] ar) { A _thread = new A(); _thread.start();//run thread } } 이전 1 다음