The processor thread (the await method)
while (!available) { wait(); }
Socket socket = this.socket;
available = false; notifyAll();
return socket;
The connector thread (the assign method)
while (available) { wait(); }
this.socket = socket;
available = true;
notifyAll();
Initially, when the "processor thread" has just been started, available is false, so the thread waits inside the while loop (see Column 1 of Table 4.1). It will wait until another thread calls notify or notifyAll. This is to say that calling the wait method
causes the "processor thread" to pause until the "connector thread" invokes the notifyAll method for the HttpProcessor instance. Now, look at Column 2. When a new socket is assigned, the "connector thread" calls the HttpProcessor's assign method. The value of available is false, so the while loop is skipped and the socket is assigned to the HttpProcessor instance's socket variable: this.socket = socket;
The "connector thread" then sets available to true and calls notifyAll. This wakes up the processor thread and now the value of available is true so the program controls goes out of the while loop: assigning the instance's socket to a local variable, sets available to false, calls notifyAll, and returns the socket, which eventually causes the socket to be processed. Why does the await method need to use a local variable (socket) and not return the instance's socket variable? So that the instance's socket variable can be assigned to the next incoming socket before the current socket gets processed completely. Why does the await method need to call notifyAll? Just in case another socket arrives when the value of available is true. In this case, the "connector thread" will stop inside the assign method's while loop until the nofifyAll call from the "processor thread" is received.
分享到:
相关推荐
jakarta-tomcat connector linux环境
本人电脑上已经配置好的相关配置文件 ...tomcat-connectors-1.2.40-windows-x86_64-httpd-2.4.x.zip httpd.conf server.xml(tomcat) mod_jk.conf uriworkermap.properties vhosts.conf workers.properties
iis、tomcat、apache整合工具。tomcat_iis_connector WINDOWS SERVER
请注意版本号和系统位数
关于在tomcat上进行mule多线程数量参数配置
NULL 博文链接:https://skanion.iteye.com/blog/1172420
AJP Connector, 基于AJP协议,AJP是专门设计用来为tomcat与http服务器之间通信专门定制的协议,能提供较高的通信速度和效率。如与Apache服务器集成时,采用这个协议。 APR HTTP Connector, 用C实现,通过JNI调用...
《深入剖析Tomcat》深入剖析Tomcat 4和Tomcat 5中的每个组件(如果TOMCAT版本有点老,不过现在的Tomcat6和7同样可以借鉴参考),并揭示其内部工作原理。通过学习《深入剖析Tomcat》,你将可以自行开发Tomcat组件,或者...
编译tomcat所需要的jar包,因为网络原因、代理设置等,也许无法下载完整,此处给出下载好的依赖包
Threads:tomcat线程,可以查看线程的状态等信息,还可以杀死线程 Cluster:tomcat集群 System Information:系统信息 Connectors:connector信息,可以看到每秒的请求数、响应时间等 Quick check:...
AJP Connector, 基于AJP协议,AJP是专门设计用来为tomcat与http服务器之间通信专门定制的协议,能提供较高的通信速度和效率。如与Apache服务器集成时,采用这个协议。 APR HTTP Connector, 用C实现,通过JNI...
tomcat_iis_connector目录下 修改conf\workers.properties.minimal,增加一行tomcat的位置即可
今天小编就为大家分享一篇关于Tomcat中的Connector配置讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
tomcat-connectors
tomcat集群可以用到的tomcat连接,若资源有问题,欢迎在评论区留言
omcat9.0.34+mysql-connector-java-8.0.19匹配的版本,不在烦恼版本兼容问题,有用请点赞
在使用tomcat时,经常会遇到连接数、线程数之类的配置问题,要真正理解这些概念,必须先了解Tomcat的连接器(Connector)。 在前面的文章 详解Tomcat配置文件server.xml 中写到过:Connector的主要功能,是接收连接...
连接器及其支持类(HttpConnector和HttpProcessor); 表示HTTP请求类(HttpRequest)及其支持类 表示HTTP响应了(HttpResponse)及其支持类 外观类(HttpRequestFacade和HttPResponseFacade) 常量类 核心模块,...