博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
webservice如何创建线程来响应客户端
阅读量:5734 次
发布时间:2019-06-18

本文共 2731 字,大约阅读时间需要 9 分钟。

hot3.png

webservice如何创建线程来响应客户端

以tomcat为例,服务器不是必须每一个request都创建线程来响应,tomcat可以维持一个线程池来响应.

The Executor (thread pool)

Table of Contents
Introduction

The Executor represents a thread pool that can be shared between components in Tomcat. Historically there has been a thread pool per connector created but this allows you to share a thread pool, between (primarly) connector but also other components when those get configured to support executors

The executor has to implement the org.apache.catalina.Executor interface.

The executor is a nested element to the  element. And in order for it to be picked up by the connectors, the Executor element has to appear prior to the Connector element in server.xml

Attributes
Common Attributes

All implementations of Executor support the following attributes:

Attribute Description
className

The class of the implementation. The implementation has to implement the org.apache.catalina.Executor interface. This interface ensures that the object can be referenced through its name attribute and that implements Lifecycle, so that it can be started and stopped with the container. The default value for the className isorg.apache.catalina.core.StandardThreadExecutor

name

The name used to reference this pool in other places in server.xml. The name is required and must be unique.

Standard Implementation

The default implementation supports the following attributes:

Attribute Description
threadPriority

(int) The thread priority for threads in the executor, the default is 5 (the value of the Thread.NORM_PRIORITY constant)

daemon

(boolean) Whether the threads should be daemon threads or not, the default is true

namePrefix

(String) The name prefix for each thread created by the executor. The thread name for an individual thread will be namePrefix+threadNumber

maxThreads

(int) The max number of active threads in this pool, default is 200

minSpareThreads

(int) The minimum number of threads always kept alive, default is 25

maxIdleTime

(int) The number of milliseconds before an idle thread shutsdown, unless the number of active threads are less or equal to minSpareThreads. Default value is 60000(1 minute)

maxQueueSize

(int) The maximum number of runnable tasks that can queue up awaiting execution before we reject them. Default value is Integer.MAX_VALUE

prestartminSpareThreads

(boolean) Whether minSpareThreads should be started when starting the Executor or not, the default is false

threadRenewalDelay

After a context is stopped, threads in the pool are renewed. To avoid renewing all threads at the same time, this delay is observed between 2 threads being renewed. Value is in ms, default value is 1000ms. If negative, threads are not renewed.

转载于:https://my.oschina.net/u/138995/blog/225057

你可能感兴趣的文章
添加虚拟子网
查看>>
Ubuntu 12.04 root用户登录设置
查看>>
存储过程点滴
查看>>
Maven编译跳过test的设置
查看>>
SQLyog图形化l数据库的操作和学习
查看>>
[LeetCode]22.Generate Parentheses
查看>>
WEB前端 CSS选择器
查看>>
计算A/B Test需要的样本量
查看>>
二叉树前序中序后序遍历的非递归方法
查看>>
mysql 行转列列转行
查看>>
《设计模式系列》---桥接模式
查看>>
[Unity3d]Shader 着色器 学习前了解知识
查看>>
Linux中文件颜色所代表的属性和颜色
查看>>
Redrain duilib中事件委托存在的问题
查看>>
43、我的C#学习笔记9
查看>>
网站建表实践及优化
查看>>
字符串的简单操作
查看>>
C#新功能--命名参数与可选参数
查看>>
strtok和strtok_r
查看>>
维辰超市:借助云商城成功转型新零售
查看>>