servlet - thread safe
------
servlet's thread mode
by default, each servlet has only one instance,
each request will have it's own thread to access the single servlet instance,
the thread safe is related to JVM memory mode,
fields & thread safe:
* static fields
for static fields of servlet, has only one copy, might be accessed by multi thread concurrently, so there might be thread unsafe,
* non-static fields
for non-static fields of servlet,
* local variable of non-static method
for local variable of non-static method,each thread has it's own copy of the local variable, so it's totally thread safe,
------
possible thread unsafe
* static fields of servlet
all thread access the same variable, so it's thread unsafe,
* non-static fields
usually, it's safe,
but according to JVM memory mode, in some special case(e.g. thread sleep), the memory might not be synchronized, thus there might be thread unsafe,
*
------
ways to make thread safe
* take case of your program
servlet is born to be thread safe, so if you wirte good program you will be safe,
* use synchronized keyword
use synchronized on fields/method/code_block, so that only one thread could access concurrently,
drawback: of course this will reduce efficiency more or less, but it provide thread safe,
* use local variable
local variable of method is totally thread safe,
* implement SingleThreadModel interface (deprecated)
since servlet2.4 this interface is deprecated, so don't use this in most case,
servlet that implement SingleThreadModel, will create a new servlet instance for each request,
so this is totally safe, but low efficiency and expensive,
*
------
分享到:
相关推荐
赠送jar包:jakarta.servlet-api-4.0.4.jar; 赠送原API文档:jakarta.servlet-api-4.0.4-javadoc.jar; 赠送源代码:jakarta.servlet-api-4.0.4-sources.jar; 赠送Maven依赖信息文件:jakarta.servlet-api-4.0.4....
赠送jar包:jakarta.servlet-api-4.0.4.jar; 赠送原API文档:jakarta.servlet-api-4.0.4-javadoc.jar; 赠送源代码:jakarta.servlet-api-4.0.4-sources.jar; 赠送Maven依赖信息文件:jakarta.servlet-api-4.0.4....
javax.servlet-api-***.jar中文文档.zip,java,javax.servlet-api-***.jar,javax.servlet,javax.servlet-api,***,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,javax,servlet,api,中文API文档,手册,开发...
赠送jar包:javax.servlet-api-4.0.0.jar; 赠送原API文档:javax.servlet-api-4.0.0-javadoc.jar; 赠送源代码:javax.servlet-api-4.0.0-sources.jar; 赠送Maven依赖信息文件:javax.servlet-api-4.0.0.pom; ...
赠送jar包:javax.servlet-api-4.0.1.jar; 赠送原API文档:javax.servlet-api-4.0.1-javadoc.jar; 赠送源代码:javax.servlet-api-4.0.1-sources.jar; 赠送Maven依赖信息文件:javax.servlet-api-4.0.1.pom; ...
Servlet-api.jar是Java Web开发中不可或缺的一个库文件,它包含了Servlet和JSP(JavaServer Pages)规范的API接口。这个库文件主要用于与Web服务器交互,处理HTTP请求,并生成响应。在本文中,我们将深入探讨Servlet...
javax.servlet-api-***.jar中文文档.zip,java,javax.servlet-api-***.jar,javax.servlet,javax.servlet-api,***,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,javax,servlet,api,中文API文档,手册,开发...
javax.servlet-api-***.jar中文文档.zip,java,javax.servlet-api-***.jar,javax.servlet,javax.servlet-api,***,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,javax,servlet,api,中文API文档,手册,开发...
赠送jar包:jersey-container-servlet-core-2.22.2.jar; 赠送原API文档:jersey-container-servlet-core-2.22.2-javadoc.jar; 赠送源代码:jersey-container-servlet-core-2.22.2-sources.jar; 赠送Maven依赖信息...
赠送jar包:javax.servlet-3.0.0.v201112011016.jar; 赠送原API文档:javax.servlet-3.0.0.v201112011016-javadoc.jar; 赠送源代码:javax.servlet-3.0.0.v201112011016-sources.jar; 赠送Maven依赖信息文件:...
赠送jar包:sentinel-web-servlet-1.8.0.jar; 赠送原API文档:sentinel-web-servlet-1.8.0-javadoc.jar; 赠送源代码:sentinel-web-servlet-1.8.0-sources.jar; 赠送Maven依赖信息文件:sentinel-web-servlet-...
jakarta.servlet-api-4.0.4.jar jakarta.servlet-api-4.0.4-javadoc.jar jakarta.servlet-api-4.0.4-sources.jar
javax.servlet-api-3.1.0.jar,处理找不到servlet JAR的问题
赠送jar包:javax.servlet-api-4.0.0.jar; 赠送原API文档:javax.servlet-api-4.0.0-javadoc.jar; 赠送源代码:javax.servlet-api-4.0.0-sources.jar; 赠送Maven依赖信息文件:javax.servlet-api-4.0.0.pom; ...
文件中包含javax.servlet-api-3.0.1.jar,javax.servlet-api-3.1.0.jar,javax.servlet-api-4.0.0.jar,用来处理java项目运行中找不到servlet JAR的问题,需要的朋友可以下载
servlet源代码本来就是开放的,CSDN居然那么多人要...本资源是来自从Maven的servlet-api-3.1源代码,原地址还有servlet-api、servlet-api-doc,本资源仅仅下载了源代码的部分,需要的朋友可以去以下网址下载其它内容: ...
servlet-api.jar
Servlet-api-3.0.jar是Java Servlet API的第三版实现,它是开发Web应用程序的重要组成部分,特别是在基于Java的服务器端编程中。这个库包含了用于创建和管理HTTP服务端点的接口和类,允许开发者构建动态、交互式的...
Servlet-API是Java Servlet技术的核心部分,它定义了服务器端与客户端之间交互的一系列接口和类。这个压缩包包含了Servlet-API的多个版本,分别是2.2、2.3、2.4、2.5以及3.0。每个版本的发布都带来了新的功能和改进...