请问这是什么错误?
//我用的eclipse
package Chapter10; //这里有提示说A class file was not written......然后就无法run,请问是为什么?下面的代码都没报错了。
public class producor {
public static void main(String[] args) {
quantity q=new quantity();
new Pro(q);
new con(q);
System.out.println("a a a");
}
}
class quantity
{
int n;
boolean b=false;
synchronized int get()
{
if(!b)
try{
wait();
}catch(InterruptedException e){
System.out.println("catch");
}
System.out.println("a"+n);
b=false;
notify();
return n;
}
synchronized void put(int n)
{
if(b)
try
{
wait();
}catch(InterruptedException e){
System.out.println("put errors");
}
this.n=n;
b=true;
System.out.println("put"+n);
notify();
}
}
class Pro implements Runnable
{
quantity q;
Pro(quantity q)
{
this.q=q;
new Thread(this,"Pro").start();
}
public void run() {
int i=0;
while(true)
{
q.put(i++);
}
}
}
class con implements Runnable
{
quantity q;
con(quantity q)
{
this.q=q;
new Thread(this,"con").start();
}
public void run()
{
while(true)
{
q.get();
}
}
}