一个JAVA源文件中最多只能有一个public class,此class的名字必须同文件名一样。
你定义了两个public class,也可以把class waitNotify 的public 去掉就行乐。
你定义了两个public class,也可以把class waitNotify 的public 去掉就行乐。
解决方案 »
- Map 集合明明使用了泛型,为什么说我不安全操作,
- 一个整型数组中有一半以上的数是相同的,如何找到这个数
- hibernate如何取消延迟加载效果
- 初学java,遇到个小难题,小第请路过的高人指教啊.在线等,急啊!!
- 外国一家公司的一道超难推理面试题,如果你做对了,直接录取拿5K以上的工资不成问题!!!!!!
- 请教java如何实现向指定端口(如COM1)输出数据流?
- 如何用JAVA读取会员卡的信息?
- 欢迎加入天地联盟之计算机20836124,大家一起进步哈!!!
- java的三角形!
- 请问在Java中,可以使用类似javascript 中的 prototype 这样的原型功能吗?
- 请问Jbuilder中运行application是用哪个程序?
- 急:java中如何与word通讯?
import java.applet.*;class Dealer
{
int goods=0;
public synchronized int consume()
{
int temp;
while (goods==0)
{
try {wait();}
catch(interruptedException e){}
}
temp=goods;
goods=0;
System.out.println("Consumed:"+temp);
notify();
return temp;
}
public synchronized void produce(int amount)
{
while (goods!=0)
{ try
{
wait();
}
catch (InterruptedExceptioon e){}
}
goods=amount;
notify();
System.out.println("Produced:"+goods);
}
}class myThread extends Thread
{
boolean prouducer=false;
Dealer dealer;
public myThread(Dealer d,String type)
{
dealer=d;
if (type.equals("producer"))
producer=true;
}
public void run()
{
for (int i=0;i<10;i++)
{try {sleep((int)(Math.random()*200));}
catch (InterruptedException e){}
if (producer)
dealer.produce((int)(Math.random()*10)+1);
else
dealer.consume();
}
}
}
public class waitNotify extends Applet
{
Dealer dealer=new Dealer();
public void init()
{
new myThread(dealer,"Consumer").start();
new myThread(dealer,"Producer").start(); }
}
并且文件名改为waitNotify反倒出现更多错误:
C:\vj\MyProjects\waitNotify\waitNotify.java(37,14) : error J0049: Undefined name 'InterruptedExceptioon'
C:\vj\MyProjects\waitNotify\waitNotify.java(37,14) : error J0044: Cannot find definition for class 'InterruptedExceptioon'
C:\vj\MyProjects\waitNotify\waitNotify.java(22,11) : error J0049: Undefined name 'interruptedException'
C:\vj\MyProjects\waitNotify\waitNotify.java(22,11) : error J0044: Cannot find definition for class 'interruptedException'
C:\vj\MyProjects\waitNotify\waitNotify.java(60,8) : error J0049: Undefined name 'producer'
C:\vj\MyProjects\waitNotify\waitNotify.java(53,6) : error J0049: Undefined name 'producer'
这是为什么?
请指点
InterruptedExceptioon -> InterruptedException
interruptedException -> InterruptedException