public synchronized static void method() {
if (ticket > 0) {
System.out.println(Thread.currentThread().getName() + "正在销售第" + (1001 - ticket) + "张票");
ticket--;
}
if (ticket <= 0) {
System.out.println(Thread.currentThread().getName() + "票已售完");
}
}
public static synchronized void method() {
if (ticket > 0) {
System.out.println(Thread.currentThread().getName() + "正在销售第" + (1001 - ticket) + "张票");
ticket--;
}
if (ticket <= 0) {
System.out.println(Thread.currentThread().getName() + "票已售完");
}
请问这两个有区别吗?