public class Foo2 {
private int x = 100
public int getX() {
return x
}
//同步方法
public synchronized int fix(int y) {
x = x - y
System.out.println("线程"+Thread.currentThread().getName() + "运行结束,减少“" + y + "”,当前值为:" + x)
return x
}
}
欢迎分享,转载请注明来源:内存溢出
public class Foo2 {
private int x = 100
public int getX() {
return x
}
//同步方法
public synchronized int fix(int y) {
x = x - y
System.out.println("线程"+Thread.currentThread().getName() + "运行结束,减少“" + y + "”,当前值为:" + x)
return x
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)