📄 producer.java
字号:
import javax.swing.*;
public class Producer extends Thread
{
private Buffer sharedLocation;
private JTextArea outputArea;
public Producer(Buffer shared,JTextArea output)
{
super("Producer");
sharedLocation=shared;
outputArea=output;
}
public void run()
{
for(int i=11;i<=20;i++)
{
try
{
Thread.sleep((int)(Math.random()*3000));
sharedLocation.set(i);
}
catch(InterruptedException exception)
{
exception.printStackTrace();
}
}
String name=getName();
SwingUtilities.invokeLater(new RunnableOutput(outputArea,"\n"+name+" done producing.\n"+
name+" terminated.\n"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -