Concurrent parallel multithreading

Source: Internet
Author: User

Servlet multithreading synchronization problem (important)
One of the main reasons is that the servlet is a singleton pattern, and a servlet provides services to all users, potentially creating a pattern of resource clutter

Multi-threaded synchronization problem for Servlets: The servlet itself is a single instance, so that when multiple users access a servlet at the same time, the member variables in that unique servlet instance are accessed, and if a member variable is written, it can lead to multithreading problems for the servlet. That data is inconsistent.

Scenarios for resolving synchronization issues:
1. Remove instance variables, use local variables (best)
2. Using synchronized{}

1, servlet/jsp Technology and ASP, PHP, and so on, because of its multi-threaded operation and has a high execution efficiency.

2, because servlet/jsp is executed in multithreaded mode by default, it is necessary to consider multithreading synchronization problem very carefully when writing code.

3, if in writing servlet/jsp program is not aware of the problem of multi-threaded synchronization, which often results in writing programs in a small number of users do not have any problems, and when the concurrent users rise to a certain value, will often appear some puzzling problem, for this kind of randomness problem debugging is also very difficult.




Multithreaded Programming Idea: http://www.cnblogs.com/Autumoon/archive/2008/06/19/1225684.html


Parallel: Refers to both from the micro or macro, both are executed together, as if two people each take a shovel in digging pit, an hour later, each person a big pit.

Concurrency: Not at the same time in the micro-execution, but divided into several paragraphs, so that multiple processes quickly alternating execution, from the macroscopic perspective, it seems that these processes are in execution, it is like two people with the same shovel, take turns digging pits, an hour later, two people dug a small point of the pit, to dig two a little bigger pits, It will take two hours.
From the above essence is not difficult to see, "concurrent" execution, in multiple processes there is a resource conflict, and did not improve the efficiency of the implementation at all.

The difference between concurrency and parallelism is that a person eats three steamed buns at the same time (a pit of three people alternately digs) and three people eat three steamed buns at the same time (three pits three people dig one by one).

Concurrent parallel multithreading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.