我現在是用 Win 7 RC 7100 32 bit
現在在學 Java
底下這隻程式在 xp 下就正常
在 win 7 會有怪異情形
在 synchronized 的情況下
while 迴圈竟然會出錯 覺得有點誇張
public class SyncShareData implements Runnable
{
int i;
public void run()
{
while (i<10)
{
synchronized(this)
{
i++;
for(int j=0; j<10000000; j++);
System.out.println(Thread.currentThread().getName()+":"+i);
}
}
}
}
public class ThreadsExample4
{
public static void main(String argv[])
{
SyncShareData s = new SyncShareData();
Thread t1 = new Thread(s);
Thread t2 = new Thread(s);
t1.start();
t2.start();
}
}




























































































