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

广州网站推广软件世界之窗附近做网站公司

广州网站推广软件,世界之窗附近做网站公司,合肥房产网58同城,怎么免费发布网站Thread-Per-Message是为每一个消息的处理开辟一个线程,以并发方式处理,提高系统整体的吞吐量。这种模式再日常开发中非常常见,为了避免线程的频繁创建和销毁,可以使用线程池来代替。 示例代码如下: public class Requ…

    Thread-Per-Message是为每一个消息的处理开辟一个线程,以并发方式处理,提高系统整体的吞吐量。这种模式再日常开发中非常常见,为了避免线程的频繁创建和销毁,可以使用线程池来代替。

示例代码如下:

public class Request {
private String business;public Request(String business) {
this.business=business;
}
public String toString() {
return this.business;
}
}
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;public class TaskHandler implements Runnable{
private Request request;public TaskHandler(Request request) {
this.request=request;
}private void slowly() {
try {
TimeUnit.SECONDS.sleep(ThreadLocalRandom.current().nextInt(10));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}@Override
public void run() {
System.out.println("Begin handle "+request);
slowly();
System.out.println("End handle "+request);
}}
import org.multithread.threadpool.BaseThreadPool;
import org.multithread.threadpool.ThreadPool;public class Operator {
private final ThreadPool threadPool=new BaseThreadPool(2,6,4,100);public void call(String business) {
TaskHandler taskHandler=new TaskHandler(new Request(business));
threadPool.execute(taskHandler);
}}
public class TPMtest {
public static void main(String[] args) {
Operator op=new Operator();
String root="Root-Request-";
for(int i=0;i<30;i++) {
op.call(root+i);
}
}
}

运行结果:

Begin handle Root-Request-0
Begin handle Root-Request-1
End handle Root-Request-1
Begin handle Root-Request-2
End handle Root-Request-0
Begin handle Root-Request-3
End handle Root-Request-3
Begin handle Root-Request-4
End handle Root-Request-2
Begin handle Root-Request-5
Begin handle Root-Request-6
Begin handle Root-Request-7
End handle Root-Request-7
Begin handle Root-Request-8
End handle Root-Request-4
Begin handle Root-Request-9
End handle Root-Request-6
Begin handle Root-Request-10
End handle Root-Request-5
Begin handle Root-Request-11
End handle Root-Request-8
Begin handle Root-Request-12
Begin handle Root-Request-13
End handle Root-Request-10
Begin handle Root-Request-14
End handle Root-Request-9
Begin handle Root-Request-15
End handle Root-Request-11
Begin handle Root-Request-16
End handle Root-Request-15
Begin handle Root-Request-17
End handle Root-Request-14
Begin handle Root-Request-18
End handle Root-Request-18
Begin handle Root-Request-19
End handle Root-Request-12
Begin handle Root-Request-20
End handle Root-Request-20
Begin handle Root-Request-21
End handle Root-Request-16
Begin handle Root-Request-22
End handle Root-Request-22
Begin handle Root-Request-23
End handle Root-Request-23
Begin handle Root-Request-24
End handle Root-Request-13
Begin handle Root-Request-25
End handle Root-Request-19
Begin handle Root-Request-26
End handle Root-Request-26
Begin handle Root-Request-27
End handle Root-Request-27
Begin handle Root-Request-28
Begin handle Root-Request-29
End handle Root-Request-25
End handle Root-Request-17
End handle Root-Request-21
End handle Root-Request-24
End handle Root-Request-28
End handle Root-Request-29

http://www.yayakq.cn/news/189462/

相关文章:

  • 设计网站如何推广方案十堰网络推广平台
  • 南宁网站建公司电话号码厦门人才网个人会员登录
  • 常见的网站结构做网站 淘宝
  • 有自己域名的个人网站企业网站建设公司 宣武
  • 东莞网站建设推广品众如何学习网站建设
  • 网站开发的经费预算什么是网页开发
  • 昆明 五华 网站建设广西网站设计公司
  • 下载了网站源码北京百度推广代理公司
  • 手机网站大全免费网站建设开发报价方案
  • 网站源码怎么搭建3网站建设公司
  • 住房城乡建设部网站通报WordPress在线转义
  • 网站重要组成部分做网站有什么关于财务的问题
  • 用动物做logo的旅游网站网页代做价格
  • 加拿大pc网站搭建网站备案系统
  • 网站建设进展推进表苏州网站开发电话
  • 做汽配的 哪一个网站比较好做房地产销售的基础知识
  • 聊城那里有做网站江门网站设计华企立方
  • 佛山市官网网站建设公司织梦网如何把做网站的删掉
  • 怎样注册网站网站设计的研究方法
  • wordpress 建站五分钟高明搜索seo
  • 网站背景修改建设一个网站需要条件
  • 做网站公示上海建设工程安全质量监督站网站
  • 合肥餐饮网站建设网络营销服务是什么
  • 台州网站公司那里好网站建设设计外包公司
  • 去菲律宾做it网站开发文件外链网站
  • 深圳网站建设网络公司郑州网络营销
  • 网站内页标题怎么填qq刷赞网站推广快速
  • 电信改公网ip可以做网站吗网站备案及管理的授权书
  • 做淘宝必备的网站H5响应式网站示例
  • 免费网页设计成品下载手机网站优化排名首页