[size=medium] @Override
public synchronized void run() {
for (int i = 0; i < 100; ++i) {
System.out.println("Thread ID: " + this.threadId + " : " + i);
}
}
}
解决方法:将run方法加上synchronized 以保证一致性[/size]
public synchronized void run() {
for (int i = 0; i < 100; ++i) {
System.out.println("Thread ID: " + this.threadId + " : " + i);
}
}
}
解决方法:将run方法加上synchronized 以保证一致性[/size]