进程并发演示模型

进程并发演示模型

ID:38374655

大小:67.38 KB

页数:6页

时间:2019-06-11

进程并发演示模型_第1页
进程并发演示模型_第2页
进程并发演示模型_第3页
进程并发演示模型_第4页
进程并发演示模型_第5页
资源描述:

《进程并发演示模型》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassCZFrameextendsJFrameimplementsActionListener{CZThreadthread1,thread2,thread3;JButtonwait1=newJButton("等待"),wait2=newJButton("等待"),wait3=newJButton("等待");JButtonexit=newJButton("退出");JLabelnam

2、e=newJLabel("作者:谢滨宇");publicCZFrame(intn1,intn2,intn3){setTitle("进程并发演示模型");setSize(500,550);setVisible(true);thread1=newCZThread(n1);thread2=newCZThread(n2);thread3=newCZThread(n3);Containercontainer=getContentPane();container.setLayout(null);container.add(thre

3、ad1.panel);container.add(thread2.panel);container.add(thread3.panel);wait1.setBounds(400,150,70,30);wait2.setBounds(400,250,70,30);wait3.setBounds(400,350,70,30);exit.setBounds(200,450,70,30);container.add(wait1);container.add(wait2);container.add(wait3);contain

4、er.add(exit);wait1.addActionListener(this);wait2.addActionListener(this);wait3.addActionListener(this);exit.addActionListener(this);JLabellabel=newJLabel("进程并发演示模型");Fontfont=newFont("宋体",Font.BOLD,16);label.setFont(font);label.setBounds(175,20,180,50);container

5、.add(label);name.setBounds(400,40,100,50);container.add(name);thread1.start();thread2.start();thread3.start();}publicvoidactionPerformed(ActionEvente){Objects=e.getSource();if(s==exit){/*thread1.suspend();thread2.suspend();thread3.suspend();*/inti=JOptionPane.sh

6、owConfirmDialog(null,"确认退出吗?","退出",JOptionPane.YES_NO_OPTION);if(i==0)System.exit(0);/*thread1.resume();thread2.resume();thread3.resume();*/}elseif(s==wait1){try{if(thread1.st==0){thread1.suspend();thread1.st=1;wait1.setText("执行");thread1.num--;}else{thread1.res

7、ume();thread1.st=0;wait1.setText("等待");thread1.num++;}}catch(Exceptione1){}}elseif(s==wait2){try{if(thread2.st==0){thread2.suspend();thread2.st=1;wait2.setText("执行");thread1.num--;}else{thread2.resume();thread2.st=0;wait2.setText("等待");thread1.num++;}}catch(Exce

8、ptione1){}}else{try{if(thread3.st==0){thread3.suspend();thread3.st=1;wait3.setText("执行");thread1.num--;}else{thread3.resume();thread3.st=0;wait3.setText("等待");thread1

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。