java中返回的下斜线出错_java程序错误,提示我画斜杠的地方有问题,不知道什么问题?...

classComputer{privateStringbrand;privateStringmodel;privatefloatprice;privateintnumber=0;privatebooleanflag=true;privatebooleanflagProToCon=true;publicbooleanisFlagProToC...

class Computer {

private String brand;

private String model;

private float price;

private int number = 0;

private boolean flag = true;

private boolean flagProToCon = true;

public boolean isFlagProToCon() {

return flagProToCon;

}

public void setFlagProToCon(boolean flagProToCon) {

this.flagProToCon = flagProToCon;

}

public String getBrand() {

return brand;

}

public void setBrand(String brand) {

this.brand = brand;

}

public String getModel() {

return model;

}

public void setModel(String model) {

this.model = model;

}

public float getPrice() {

return price;

}

public void setPrice(float price) {

this.price = price;

}

public int getNumber() {

return number;

}

public void setNumber(int number) {

this.number = number;

}

public boolean isFlag() {

return flag;

}

public void setFlag(boolean flag) {

this.flag = flag;

}

public void stateChange(){

this.flag = !this.flag;

}

}

class Consumer implements Runnable{

private Computer com = new Computer();

public Consumer(Computer com){

this.com = com;

}

public void run(){

while(this.com.isFlag()){

synchronized(this.com){

if(this.com.isFlagProToCon()){

try{

this.com.wait();

}catch(Exception e){

e.printStackTrace();

}

}

}

try{

Thread.sleep(200);

}catch(Exception e){

e.printStackTrace();

}

System.out.println("Brand:"+this.com.getBrand()+" Mode:"+this.com.getModel()+

" Price:"+this.com.getPrice()+" this is the"+this.com.getNumber()+"st");

this.com.setFlagProToCon(!this.com.isFlagProToCon());

this.com.notify();

}

}

}

t提示我画斜杠的地方有问题,不知道什么问题?

Brand:dell Mode:Ins14ZD-3526 Price:4000.0 this is the1st

Exception in thread "Thread-1" java.lang.IllegalMonitorStateException: current thread not owner

已找出问题

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值