지금 쓰래드 동기화 공부중인데
class matha
{
public static int n = 0;
public void sum()
{
synchronized (this)
{
for(int A=0;A<10000;A++)
{
n++;
}
}
}
}
class thre extends Thread
{
matha qqq = new matha();
public void run()
{
qqq.sum();
}
}
public class t05
{
public static void main(String[] args)
{
thre t1 = new thre();
thre t2 = new thre();
t1.start();
t2.start();
try {
t1.join();
t2.join();
}
catch (InterruptedException e)
{
e.printStackTrace()
}
System.out.println(matha.n)
}
}
이러면 20000이 출력되야 하는거 아니야??
자바 병신에게 자비좀
비쥬얼 스튜디오 얼티밋 설치중인데요... 님아 자바좀 갈쳐주심..!
우오 ㅅㅅ형 ㄳㄳ 각각의 인스턴스가 됬었구나 진짜 ㄳㄳ
짤 좆같아서 안해줌