当前位置: 首页 > news >正文

nft制作网站谷歌关键词搜索排名

nft制作网站,谷歌关键词搜索排名,网络技术论坛,鲜花培训网站建设操作系统课程设计#xff1a;实现进程间的同步。 有问题留言import java.util.concurrent.Semaphore; /******** 信号量 *******/ class Sign { final static int NUMS 6; // 进程的数目 final static int RUN 1; // 运行完 final static int STOP 0; // 阻塞态 static int…操作系统课程设计实现进程间的同步。 有问题留言import java.util.concurrent.Semaphore; /******** 信号量 *******/ class Sign { final static int NUMS 6; // 进程的数目 final static int RUN 1; // 运行完 final static int STOP 0; // 阻塞态 static int[] status new int[NUMS]; // 进程的状态 不运行 则阻塞 默认为禁止 static Semaphore s[] null; // 信号量 final static int[] times new int[6]; //运行的次数 static Semaphore mutex new Semaphore(1);// 信号量控制对临界区的访问 static { s new Semaphore[NUMS]; for (int i 0; i NUMS; i) { s[i] new Semaphore(1); // 初始化 } for (int j 0; j times.length; j) { times[j] 10; // 每个进程执行10次则结束 } } } /*********线程***********/ class process6 implements Runnable {// 进程线程 private int id; public process6(int id) { super(); this.id id; } void test(int id) throws InterruptedException { // 测试当前进程是否可以运行 // 当自己没有运行前置条件满足时 可以运行 switch (id) { case 0: if (Sign.times[0] 0) { Sign.s[0].release(); Sign.times[0]--; System.out.println(I am thread P (id 1) 。。。。。 Sign.times[id]); } ; break; case 1: if (Sign.status[0] Sign.RUN Sign.times[1] 0) { // 如果进程1 // 已经运行完进程2可以直接运行 Sign.s[1].release(); Sign.times[1]--; System.out.println(I am thread P (id 1) 。。。。。 Sign.times[id]); } ; break; case 2: if (Sign.status[0] Sign.RUN Sign.times[2] 0) { // 如果进程1 // 已经开启进程3可以直接运行 Sign.s[2].release(); Sign.times[2]--; System.out.println(I am thread P (id 1) 。。。。。 Sign.times[id]); } ; break; case 3: if (Sign.status[1] Sign.RUN Sign.times[3] 0) { // 如果进程2已经开启进程4可以直接运行 Sign.s[3].release(); Sign.times[3]--; System.out.println(I am thread P (id 1) 。。。。。 Sign.times[id]); } ; break; case 4: if (Sign.times[4] 0 (Sign.status[1] Sign.RUN || Sign.status[2] Sign.RUN)) {// 如果进程2、或3已经运行完进程5可以直接运行 Sign.s[4].release(); Sign.times[4]--; System.out.println(I am thread P (id 1) 。。。。。 Sign.times[id]); } ; break; case 5: if (Sign.times[5] 0 (Sign.status[4] Sign.RUN || Sign.status[3] Sign.RUN)) {// 如果进程4或5已经运行完进程6可以直接运行 Sign.s[5].release(); Sign.times[5]--; System.out.println(I am thread P (id 1) 。。。。。 Sign.times[id]); } ; break; } } void print() {// 打印 每个进程的状态 for (int i 0; i Sign.NUMS; i) { System.out.println(Thread P (i 1) Sign.status[i]); } } Override public void run() { try { while (true) { // print(); //先打印全部进程状态 Sign.mutex.acquire(); // System.out.println(P id is testing!); test(id); Sign.mutex.release(); // 判断当前进程运行的状况不能运行 则 阻塞 Sign.s[id].acquire(); // 唤醒其他进程 不能运行 则阻塞 if (Sign.times[id] 0 || Sign.times[id] 0) { Sign.status[id] Sign.RUN; // System.out.println(P (id1) run out!); Sign.mutex.acquire(); test((id 1) % 6); test((id 2) % 6); test((id 3) % 6); test((id 4) % 6); test((id 5) % 6); Sign.mutex.release(); } else { // System.out.println(前置条件不够); Thread.currentThread().sleep((100)); } } } catch (Exception e) { e.printStackTrace(); } } } public class SYSV { /** * 任务3 进程/线程同步 */ public static void main(String[] args) { new Thread(new process6(0)).start(); new Thread(new process6(1)).start(); new Thread(new process6(2)).start(); new Thread(new process6(3)).start(); new Thread(new process6(4)).start(); new Thread(new process6(5)).start(); } }
http://wiki.neutronadmin.com/news/453915/

相关文章:

  • 青岛专业网站营销免费申请激活码
  • 河南网站关键词优化代理网络布线
  • 2023网站seo做集团网站的
  • 西安 网站 高端 公司友情链接交换软件
  • 网站直播间 是怎么做的江门北京网站建设
  • 环保局网站如何做备案证明高端网站建设 企业网站建站
  • 好看网站手机版qq官网
  • 网站建设公司 保证完成 网络推广策划案范文5篇
  • 百度怎么自己做网站吗金融品牌网站设计
  • 做自媒体小视屏哪个网站好网站建设的经验
  • wordpress做单页销售网站网站页尾版权
  • 建设学校网站前的需求分析报告wordpress电话咨询插件
  • 现代网站建设公司大型网站建站
  • 中国可信网站查询做网站有什么平台
  • 音乐网站建设教程视频教程品牌推广与传播
  • 产品包装设计公司网站网站管理员怎样管理员权限设置
  • 网站空间的控制面板首页兰州网站建设营销q479185700刷屏
  • 江西建设厅网站查询施工员网站设计的工具
  • app wordpress做专业搜索引擎优化
  • 长沙网站定制开发建设一个网站建设的课程设计书
  • 怎么使用网站模板织梦摄影网站模板
  • wordpress视频站模板建立网站时首先考虑的问题
  • 消防器材网站建设背景塘下春华网站建设
  • 网站的统计代码手机单页网站生成系统
  • 怎么介绍自己的网站建设企业信用信息网查询系统官网
  • 企业网站设计的功能麻涌建设网站
  • 域名和网站的关系东胜网站建设
  • 网站域名有什么用网站建设费是什么
  • 品牌策划与推广方案网站快速优化排名免费
  • 自己建网站需要服务器么沈阳网站建设搭建