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

网站底部特效把网站做成app

网站底部特效,把网站做成app,制作小程序网站源码,如何设计网站的链接在生产者-消费者模型中#xff0c;在原有代码基础上#xff0c;把队列独立为1个类实现#xff0c;通过公布接口#xff0c;由生产者和消费者调用。 public class Consumer implements Runnable {int n;CountDownLatch countDownLatch;public Consumer(BlockingQueueIn…在生产者-消费者模型中在原有代码基础上把队列独立为1个类实现通过公布接口由生产者和消费者调用。 public class Consumer implements Runnable {int n;CountDownLatch countDownLatch;public Consumer(BlockingQueueInteger blockingQueue, int n, CountDownLatch countDownLatch) {this.n n;this.countDownLatchcountDownLatch;}Overridepublic void run() {for(int i0;in;i){try {int curPACqueue.consume();/*System.out.println(this.toString()i处理cur);*/isPrime(cur);/* System.out.println(消费blockingQueue.size());*/} catch (InterruptedException e) {e.printStackTrace();}}System.out.println(消费者完成);countDownLatch.countDown();}int isPrime(int n){ //返回1表示判断为质数0为非质数在此没有进行输入异常检测double n_sqrt;if(n2 || n3) return 1;if(n%6!1 n%6!5) return 0;n_sqrtMath.floor(Math.sqrt((float)n));for(int i5;in_sqrt;i6){if(n%(i)0 | n%(i2)0) return 0;}return 1;}}public class Model {public static void excute(int producerNum,int consumerNum,int num,CountDownLatch countDownLatch){BlockingQueueInteger blockingQueuenew LinkedBlockingQueue(num);for(int i0;iproducerNum;i){new Thread(new Producer(blockingQueue,num/producerNum,countDownLatch)).start();}for(int i0;iconsumerNum;i){new Thread(new Consumer(blockingQueue,num/consumerNum,countDownLatch)).start();}}public static void main(String[] args) {CountDownLatch countDownLatchnew CountDownLatch(6);long sSystem.currentTimeMillis();excute(2,4,1000000,countDownLatch);try {countDownLatch.await();} catch (InterruptedException e) {e.printStackTrace();}System.out.println((double) (System.currentTimeMillis()-s)/1000);} }public class PACqueue {//Java 阻塞队列在队列为空时获取元素的线程会等待队列变为非空。当队列满时存储元素的线程会等待队列可用。private static BlockingQueueInteger blockingQueuenew LinkedBlockingQueue(1000000);public static void produce (int n)throws InterruptedException{blockingQueue.put(n);}public static int consume ()throws InterruptedException{return blockingQueue.take();}}public class Producer implements Runnable{int n;CountDownLatch countDownLatch;public Producer(BlockingQueueInteger blockingQueue, int n,CountDownLatch countDownLatch) {this.n n;this.countDownLatchcountDownLatch;}Overridepublic void run() {Random ra new Random();for(int i0;in;i){try {/* System.out.println(this.toString()i生产);*/PACqueue.produce(ra.nextInt(2000000000)1);/* System.out.println(生产blockingQueue.size());*/} catch (InterruptedException e) {e.printStackTrace();}}System.out.println(生产者完成);countDownLatch.countDown();} }
http://www.zqtcl.cn/news/837225/

相关文章:

  • 如何查看域名以前是做什么网站的网站索引下降如何解决
  • 潜江 网站建设扬中话
  • 网站建设项目方案ppt广州建站模板平台
  • 房产部门成立网站免费seo推广软件
  • python做网站好处百度指数分析报告
  • 网站建设挣钱班级介绍网页制作模板
  • 工作室 网站建设app公司
  • 自己做的网站怎么在百度搜索到网页制作论文3000字
  • 如何网站托管中国跨境电商平台有多少
  • 手机p2p网站做平面设计兼职的网站有哪些
  • 贵金属网站建设唐山网站制作工具
  • 网站入门成都网站制作沈阳
  • 接做网站单子的网站做网站要会那些ps
  • 做盗市相关网站wordpress速度优化简书
  • 贵阳手机网站建设公司国内永久免费云服务器
  • 温州做网站定制哪家网络推广公司好
  • 招聘网站怎么做线下活动网站后台管理系统怎么开发
  • 西湖区外贸网站建设商梦建站
  • 网站首页设计注意斗蟋蟀网站建设
  • 石家庄网站建设远策科技网站建设公司人员配备
  • 手机怎么建网站链接专门做鞋子的网站吗
  • 网站建设设计作品怎么写网站建设 网站内容 采集
  • 自己做网站nas如何做网站大图片
  • 网站优化定做嘉兴模板建站代理
  • 南宁做网站比较好的公司有哪些花乡科技园区网站建设
  • 网站注册平台怎么注册申请空间 建立网站吗
  • 汕头住房与城乡建设网站做网站视频 上传到哪儿
  • 东莞网站关键词优化福建个人网站备案
  • 国外获奖flash网站泉州网站制作专业
  • 万网域名注册后如何做网站教学上海app开发和制作公司