智慧团建网站入口手机版响应式网站404页面怎么做

news/2025/9/27 4:20:37/文章来源:
智慧团建网站入口手机版,响应式网站404页面怎么做,游戏外包公司,东莞网站建设都找菲凡网络AutoResetEvent, ManualResetEvent是C#中常用的线程同步方法#xff0c;在Java中可以模拟#xff0c;AutoResetEvent使用Semaphore#xff0c;增加的是许可证数量#xff0c;程序里只有一个许可证#xff0c;那么当这个许可被使用后#xff0c;就会自动锁定。相反#x…AutoResetEvent, ManualResetEvent是C#中常用的线程同步方法在Java中可以模拟AutoResetEvent使用Semaphore增加的是许可证数量程序里只有一个许可证那么当这个许可被使用后就会自动锁定。相反ManualResetEvent使用countdownlatch增加的是“latch”也就是障碍或者门闩当障碍解除时所有程序都可以运行而不被阻塞如果要实现同步就必须manual reset也就是手动加latch。import java.util.concurrent.Semaphore;import java.util.concurrent.TimeUnit;public class AutoResetEvent{private final Semaphore event;private final Integer mutex;public AutoResetEvent(boolean signalled){event new Semaphore(signalled ? 1 : 0);mutex new Integer(-1);}public void set(){synchronized (mutex){if (event.availablePermits() 0){event.release();}}}public void reset(){event.drainPermits();}public void waitOne() throws InterruptedException{event.acquire();}public boolean waitOne(int timeout, TimeUnit unit) throws InterruptedException{return event.tryAcquire(timeout, unit);}public boolean isSignalled(){return event.availablePermits() 0;}public boolean waitOne(int timeout) throws InterruptedException{return waitOne(timeout, TimeUnit.MILLISECONDS);}}AutoResetEvent在MSDN中的例子程序在http://msdn.microsoft.com/en-us/library/system.threading.autoresetevent.aspx我们可以改写一个java版本用的是java版本的AutoResetEventimport java.util.Date;import java.util.Random;class TermInfo{public long[] terms;public int order;public long baseValue;public AutoResetEvent trigger;}public class AutoResetEventTest{private final static int numTerms 3;public static void main(String[] args0) throws InterruptedException{AutoResetEvent trigger new AutoResetEvent(false);TermInfo tinfo new TermInfo();Thread termThread;long[] terms new long[numTerms];int result 0;tinfo.terms terms;tinfo.trigger trigger;for (int i 0; i numTerms; i){tinfo.order i;// Create and start the term calc thread.TermThreadProc termThreadProc new TermThreadProc(tinfo);termThread new Thread(termThreadProc);termThread.start();// simulate a number crunching delayThread.sleep(1000);Date date new Date();tinfo.baseValue Integer.parseInt(String.valueOf((date.getTime())).substring(10));trigger.set();termThread.join();result terms[i];}System.out.format(Result %d, result);System.out.println();}}class TermThreadProc implements Runnable{public TermInfo termInfo;public TermThreadProc(TermInfo termInfo){this.termInfo termInfo;}Overridepublic void run(){TermInfo tinfo termInfo;System.out.format(Term[%d] is starting..., tinfo.order);System.out.println();// set the precalculationDate date new Date();long preValue Integer.parseInt(String.valueOf((date.getTime())).substring(10)) tinfo.order;// wait for base value to be readytry{tinfo.trigger.waitOne();}catch (InterruptedException e){e.printStackTrace();}Random rnd new Random(tinfo.baseValue);tinfo.terms[tinfo.order] preValue * rnd.nextInt(10000);System.out.format(Term[%d] has finished with a value of: %d, tinfo.order, tinfo.terms[tinfo.order]);System.out.println();}}//ManualResetEvent 的Java实现import java.util.concurrent.CountDownLatch;import java.util.concurrent.TimeUnit;public class ManualResetEvent{private volatile CountDownLatch event;private final Integer mutex;public ManualResetEvent(boolean signalled){mutex new Integer(-1);if (signalled){event new CountDownLatch(0);}else{event new CountDownLatch(1);}}public void set(){event.countDown();}public void reset(){synchronized (mutex){if (event.getCount() 0){event new CountDownLatch(1);}}}public void waitOne() throws InterruptedException{event.await();}public boolean waitOne(int timeout, TimeUnit unit) throws InterruptedException{return event.await(timeout, unit);}public boolean isSignalled(){return event.getCount() 0;}public boolean waitOne(int timeout) throws InterruptedException{return waitOne(timeout, TimeUnit.MILLISECONDS);}}MSDN地址http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspxJava测试import java.util.Scanner;import java.io.IOException;public class ManualResetEventTest{// mre is used to block and release threads manually. It is// created in the unsignaled state.static AutoResetEvent mre new AutoResetEvent(false);public static void main(String[] arg0) throws IOException, InterruptedException{System.out.println(\nStart 3 named threads that block on a ManualResetEvent:\n);Scanner keyIn new Scanner(System.in);System.out.print(Press the enter key to continue);keyIn.nextLine();for (int i 0; i 2; i){threadProc threadProc new threadProc();Thread t new Thread(threadProc);t.setName(Thread_ i);t.start();}Thread.sleep(500);System.out.println(\nWhen all three threads have started, press Enter to call Set() \nto release all the threads.\n);keyIn.nextLine();mre.set();Thread.sleep(500);System.out.println(\nWhen a ManualResetEvent is signaled, threads that call WaitOne() \ndo not block. Press Enter to show this.\n);keyIn.nextLine();for (int i 3; i 4; i){threadProc threadProc new threadProc();Thread t new Thread(threadProc);t.setName(Thread_ i);t.start();}Thread.sleep(500);System.out.println(\nPress Enter to call Reset(), so that threads once again block \nwhen they call WaitOne().\n);keyIn.nextLine();mre.reset();// Start a thread that waits on the ManualResetEvent.threadProc threadProc new threadProc();Thread t5 new Thread(threadProc);t5.setName(Thread_5);t5.start();Thread.sleep(500);System.out.println(\nPress Enter to call Set() and conclude the demo.);keyIn.nextLine();mre.set();}}class threadProc implements Runnable{Overridepublic void run(){String name Thread.currentThread().getName();System.out.println(name starts and calls mre.WaitOne());try{ManualResetEventTest.mre.waitOne();}catch (InterruptedException e){e.printStackTrace();}System.out.println(name ends.);}}0顶0踩分享到 2011-04-07 16:39浏览 2539评论

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/919069.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

wordpress电影站开发福彩hao123网址导航

一、脸部修复:解决在低分辨率下,脸部生成异常的问题 勾选ADetailer,会在生成图片后,用更高的分辨率,对于脸部重新生成一遍 二、高清放大:低分辨率照片提升到高分辨率,并丰富内容细节 1、先通过…

邹城网站建设哪家好wordpress短代码页面

LB集群: (Load Balancing)即负载均衡集群,其目的是为了提高访问的并发量及提升服务器的性能,其 实现方式分为硬件方式和软件方式。 硬件实现方式: 常用的有 F5公司的BIG-IP系列、A10公司的AX系列、Citrix公司的 NetScaler系列…

洛阳网站建设报价网站建设终端是什么

接上文SpringCloud Alibaba - Nacos 1.Sentinel 流量防卫兵 1.1 安装与部署 和Nacos一样,它是独立安装和部署的,下载地址https://github.com/alibaba/Sentinel/releases 下载后的jar放到目录 然后配置 启动并访问,用户名密码都是 sentinel 此时就…

网站单页面可以做302跳转吗中国商标买卖网站

sublime php 运行环境sublime php 运行环境有时候需要用运行一段 PHP 代码,比如测试某个函数返回值等等,如果启动Http Server,再打开浏览器,那黄花菜都凉了。我们可以在 Sublime Text 3 中创建 php 的 build system,这…

网站建设服务器的选择方式包括常州承接网站建设

周鹏 本文由黄淮学院副CIO周鹏投递并参与《2023中国数智化转型升级优秀CIO》榜单/奖项评选。丨推荐企业—锐捷网络 大数据产业创新服务媒体 ——聚焦数据 改变商业 黄淮学院是2004年经教育部批准成立的一所省属全日制普通本科高校。学校位于素有“豫州之腹地、天下之最中”之美…

2015个人网站如何去工信部备案湘潭做网站 磐石网络很专业

在日常外币银行结汇的时候,汇率小数点有可能是6位,但是SAP的汇率字段长度小数点后只有5位 所以,客户在F-02的时候,会出现一下报错“条目过长” 解决方法: 更改汇率的比率 OB08重新修改汇率 F-02界面 但是这种方法的风…

采网站建设昵图网素材图库大图免费

AOP简介 AOP(Aspect oriented Programming)面向切面编程,就是面向特定的方法编程,将方法比作一个一个的切面,可以向指定的方法执行前/后执行自己的逻辑。如统一获取方法的时间。 应用场景: 记录操作日志、权限控制、事务管理 优…

世界上前端做的最好的网站淄博云天网站建设推广

计算机基础与程序设计.doc (17页)本资源提供全文预览,点击全文预览即可全文预览,如果喜欢文档就下载吧,查找使用更方便哦!14.9 积分《计算机基础与稈序设计》是高等教冇H学考试工科备专业的基础课。这门课也是大部分学 生学习计算…

网站开发毕业设计文献综述网站开发的两种模式

Python微信订餐小程序课程视频 https://edu.csdn.net/course/detail/36074 Python实战量化交易理财系统 https://edu.csdn.net/course/detail/35475 掌握JavaScript中的迭代器和生成器,顺便了解一下async、await的原理 前言 相信很多人对迭代器和生成器都不陌…

印度尼西亚网站后缀cent os安装wordpress

接口测试虽然作为版本的一环,但是也是有一套完整的体系,有接口的功能测试、性能测试、安全测试;同时,由于接口的特性,接口的自动化低成本高收益的,使用一些开源工具或一些轻量级的方法,在测试用…

网站建设视频百度网盘义乌网站建设公司

Windows server 2008 web服务器的搭建和部署相对于windows server 2003的IIS6来说,windows server 2008推出的IIS7.0为管理员提供了统一的web平台,为管理员和开发人员提供了一个一致的web解决方案。并针对安全方面做了改进,可以减少利用自定义…

ps做网站首页怎么运用起来必要是什么网站

在JavaScript中,有几种方式可以声明函数,其中最常见的有两种:函数声明和函数表达式。 一、函数声明 使用关键字 function 来声明函数,语法如下 function functionName(parameters) {// 函数体 }例子: function gre…

没有公司自己做网站广告公司取名大全最新版的

反爬虫反调试小结: 敢爬我的网站,我就炸了你的电脑!闪花你的双眼。 大家好,这一集我们来学一些非常实用的反爬小妙招。 首先我们来回顾一些非常低级的反爬,有的禁止右键,有的禁止F12,但是我们还…

长春搜索引擎网站推广手机端网站制作教程

网吧管理系统 目录 基于SprinBootvue的网吧管理系统 一、前言 二、系统设计 三、系统功能设计 1 管理员功能模块 2 网管功能模块 3 会员功能模块 四、数据库设计 五、核心代码 六、论文参考 七、最新计算机毕设选题推荐 八、源码获取: 博主介绍&#…

旅游网站技术流程图建网站建设网站

打地鼠玩具是一种经典的儿童游戏,它结合了电子技术来增加娱乐性和互动性。 电子技术的集成使得打地鼠玩具不仅能够提供基本的娱乐功能,还能够提供更多的互动性和游戏性。随着技术的发展,打地鼠玩具可能会包含更多的高级功能,如无…

贵阳网站推广百度网站排名查询

文章目录1. 题目2. 解题1. 题目 给出一个含有不重复整数元素的数组,每个整数均大于 1。 我们用这些整数来构建二叉树,每个整数可以使用任意次数。 其中:每个非叶结点的值应等于它的两个子结点的值的乘积。 满足条件的二叉树一共有多少个&…

做平面设计都在那个网站找免费素材?济南网站建设服务商

两两交换链表中的节点 leetcode24 递归 两个节点一递归 第一次即成功,泪目!! // 每两个进行一次交换 func swapPairs(head *ListNode) *ListNode {//每两个的第一个节点var pre *ListNode//递归结束条件,即当剩下的节点不满足两…

始兴生态建设网站海淘返利网站怎么做

Java数组 什么是数组 相同数组的有序集合 数组描述的是相同类型的若干个数据,按照一定先后次序排列组合而成 其中,每个数据称为一个数组元素,每个数组元素通过下标来访问 数组声明创建 首先必须声明数组变量,才能在程序中使用…

只能在线观看的电影网站咋么做赣州章贡区房价

在Oracle数据库注释用--表明为注释,但以下用//或--代表解释;数据库不怎么区分大小写; 先说说一些简单Oracle数据库操作的语句: 使用语句创建普通用户: Create user username identified by password; //创建普通用户 Grant reso…

php除了做网站还能做什么淘宝的17种免费推广方法

组织战略 战略目标 出发点 战略方针 基本依据 战略实施能力 内部外部 战略措施 重要保障 战略分解过程 自上而下 战略实施四个阶段 战略启动阶段 战略计划实施阶段 战略运作阶段 战略控制与评估阶段 组…