资源简介
ex02.rar
代码片段和文件信息
package xzt.newpark;
import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.objectInputStream;
import java.io.objectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
public class Entrance extends Jframe implements PortI Runnable {
/**
*
*/
private static final long serialVersionUID = 290382490375072605L;
private ArrayList remotePortInfs;// 该列表保存所有的Port对象(包括出口和入口)的信息
// 其中的元素是PortInfBean对象
private ArrayList applicationStack;// 保存所有待进入临界区的Message
private ArrayList entranceJoinReplyStack;// 保存所有端口发送的包含了自己状态的消息
private ServerSocket serverSocket;// socket对象 负责发送和接受消息
private PortInfBean localPortInf;// 代表自己这个节点的信息
private int unoccupiedNum;// 当前空闲车位数
@SuppressWarnings(“unused“)
private int totalParkingNum;// 总车位数
private int replyNum;// 收到的回复数
private JLabel nameLabel unoccupiedNumLabel;
private JButton carInButton;
private ActionListener listener = new MyBtnListener();
private int waitingCarNum;
// 入口状态,有RELEASED、WANTED、HELD三种状态
private STATE state;
enum STATE {
RELEASEDWANTEDHELD;
}
// 是否系统正在加入端口,如果是,则需要等到端口加入后占有临界区的入口才能释放临界区
private boolean updating;
private class MyBtnListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
object o = e.getSource();
if (o instanceof JButton) {
JButton btn = (JButton) o;
if (btn.getText().equals(“Car Enter“)) {
new Thread() {
public void run() {
if (state == STATE.RELEASED) {
state = STATE.WANTED;
apply();
} else {
waitingCarNum++;
}
showUnoccupiedNum();
}
}.start();
}
}
}
}
public Entrance(String address int port int totalParkingNum) {
super(String.valueOf(“ENTRANCE:“ + port));
try {
localPortInf = new PortInfBean(address port “entrance“);
serverSocket = new ServerSocket(port);
remotePortInfs = new ArrayList();
applicationStack = new ArrayList();
entranceJoinReplyStack = new ArrayList();
replyNum = 0;
unoccupiedNum = totalParkingNum;
this.totalParkingNum = totalParkingNum;
state = STATE.RELEASED;
waitingCarNum = 0;
updating = false;
nameLabel = new JLabel(“Unoccupied Num:“);
unoccupiedNumLabel = new JLabel(Integer
.toOctalString(this.unoccupiedNum));
carInButton = new JButton(“Car Enter“);
Container contentPane = this.getContentPane();
GridBagConstraints gbc = new GridBagConstraints();
contentPane.setLayout
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 19607 2013-12-31 16:21 newpark\Entrance.java
文件 11063 2013-12-31 16:20 newpark\Exit.java
文件 5424 2013-12-31 16:22 newpark\Initfr
文件 2137 2013-12-31 16:20 newpark\Message.java
文件 4131 2013-12-31 17:11 newpark\ParkManager.java
文件 694 2013-12-31 16:20 newpark\PortI.java
文件 1356 2013-12-31 16:20 newpark\PortInfBean.java
目录 0 2013-12-31 17:35 newpark
----------- --------- ---------- ----- ----
44412 8
- 上一篇:2.16.2_0.crx
- 下一篇:cad选中点就可以输出坐标到文件
相关资源
- 2.16.2_0.crx
- Tomasulo算法实验报告.docx
- ravemaster_1076245.rar
- Photon_english.dll
- lCD1602万年日历温度显示程序仿真.zi
- EPSONL4168L4160打印机清零软件教程步骤
- 极品私人密盘(190814).zip
- 影视.txt
- YW寄生虫.zip
- 百度连接提取码.txt
- 9Tkinter.zip
- 计算机网络谢希仁第七版课后答案完
-
unti
tled1385696325.rar - 频率计.rar
- 杨辉通信考研视频资料.docx
- qq_43391237_11004384.zip
- skyline安装包及破解文件.txt
- 坐标转换.rar
- 卡尔曼滤波源代码.rar
- poker.zip
- beta_build.dll
- 10493925-1534760938165.zip
- Main.unity
- buckboost.slx
- 零基础学习QTP自动化测试视频教程.
- sms1.2.rar
- 内含地址.txt
- 安养_易模块反编译工具[支持带密码
- KUKA和康耐视相机TCPIP通讯.pptx
- ArcGIS研习班.txt
评论
共有 条评论