Home > Java > JavaBase > body text

What is a singleton in javaweb

王林
Release: 2020-05-17 14:28:42
Original
2291 people have browsed it

What is a singleton in javaweb

What is a singleton?

The so-called singleton means that all requests are processed with an object. For example, our commonly used service and dao layer objects are usually singletons.

(Video tutorial recommendation: java video)

Why use a singleton?

1. It is because there is no need to create a new object for every request, which wastes both CPU and memory;

2. It is to prevent concurrency problems; that is, one request changes the object status, at this time the object processes another request, and the previous request's change to the object's status caused the object to incorrectly handle another request;

Recommended tutorial:Getting Started with Java Development

The above is the detailed content of What is a singleton in javaweb. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template