又出问题了!
class Computer
{
String name = "电脑主机";
boolean flag = false;
public synchronized void set(String name)
{
if(!flag)
try
{
super.wait();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
this.setName(name);
flag = false;
super.notify();
}
public synchronized void get(String name)
{
if(flag)
try
{
super.wait();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
System.out.println(this.getName());
flag = true;
super.notify();
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
class Producer implements Runnable
{
Computer computer = null;
public Producer(Computer computer)
{
this.computer = computer;
}
public void run()
{
boolean flag = false;
for(int i=0;i<10;i++)
{
if(flag)
{
this.computer.set("电脑主机");
flag = false;
}
else
{
this.computer.set("显示器");
flag = true;
}
}
}
}
class Consumer implements Runnable
{
Computer computer = null;
public Consumer(Computer computer)
{
this.computer = computer;
}
public void run()
{
for(int i=0;i<10;i++)
try
{
Thread.sleep(100);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
this.computer.getName();
}
}
public class ComputerTest
{
public static void main(String[] args)
{
Computer comp = new Computer();
Producer pro = new Producer(comp);
Consumer con = new Consumer(comp);
new Thread(pro).start();
new Thread(con).start();
}
}
出现下列提示:
F:\>javac ComputerTest.java
javac: 找不到文件: ComputerTest.java
用法: javac <options> <source files>
-help 用于列出可能的选项
本来就是放在f盘根目录先的嘛,怎么会提示找不到呢?
{
String name = "电脑主机";
boolean flag = false;
public synchronized void set(String name)
{
if(!flag)
try
{
super.wait();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
this.setName(name);
flag = false;
super.notify();
}
public synchronized void get(String name)
{
if(flag)
try
{
super.wait();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
System.out.println(this.getName());
flag = true;
super.notify();
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
class Producer implements Runnable
{
Computer computer = null;
public Producer(Computer computer)
{
this.computer = computer;
}
public void run()
{
boolean flag = false;
for(int i=0;i<10;i++)
{
if(flag)
{
this.computer.set("电脑主机");
flag = false;
}
else
{
this.computer.set("显示器");
flag = true;
}
}
}
}
class Consumer implements Runnable
{
Computer computer = null;
public Consumer(Computer computer)
{
this.computer = computer;
}
public void run()
{
for(int i=0;i<10;i++)
try
{
Thread.sleep(100);
}
catch(InterruptedException e)
{
e.printStackTrace();
}
this.computer.getName();
}
}
public class ComputerTest
{
public static void main(String[] args)
{
Computer comp = new Computer();
Producer pro = new Producer(comp);
Consumer con = new Consumer(comp);
new Thread(pro).start();
new Thread(con).start();
}
}
出现下列提示:
F:\>javac ComputerTest.java
javac: 找不到文件: ComputerTest.java
用法: javac <options> <source files>
-help 用于列出可能的选项
本来就是放在f盘根目录先的嘛,怎么会提示找不到呢?
...全文
相关推荐
modelsim仿真出问题啦?新手们要注意啦!
通过对比,发现原来是编译库路径发生改变导致的。为了解决这个问题,这里给出一种解决办法:即将工程下的modelsim.ini文件删掉就可继续仿真了。
沟通方式出了问题,孩子叛逆有原因!.docx
沟通方式出了问题,孩子叛逆有原因!.docx
孩子叛逆抑郁可能是家庭沟通出了问题!.docx
孩子叛逆抑郁可能是家庭沟通出了问题!.docx
DIICUZ!采集器更新采集Discuz!2专版
全自动采集DIICUZ目标论坛文章,采集选定区间,可筛选采集内容,自动下载远程,自动发帖.
Discuz! 6.1_jQuery兼容问题
在Discuz! 6.1中无法直接使用jQuery,此时对/include/javascript/common.js文件应用如下补丁即可。


Java SE
