Go-About multithreading

Source: Internet
Author: User
Maple Leaf Country Wanderer 2001-07-04 16:32:33
I can introduce you here, but for each programming model to see what the specific example is, and I can not give you a list of all the code, please understand.
In fact, we program as far as possible to stand at a higher level, a lot of truth in fact you will find that you have understood.
On the multithreading, we started thinking about two threads (>2 is a mathematical induction?). So what happens to two separate threads?
1. When a thread enters the moniter (that is, the station uses an object), the other thread only waits or returns, and we call the return a pattern, which is balking in English.
2. These two threads can be executed in an orderly fashion, rather than having the OS schedule, when we are scheduling with an object, which is called Scheduler. (the word and its meaning are actually in the OS).
3. If these two threads read a resource at the same time, we can let them execute it, but if you write at the same time, you will know that there may be a problem with your eyes closed, and then we will use another pattern (Read/write Lock).
4. If one thread is serving another thread, such as the thread that is responsible for data transmission in IE and the thread that the interface displays, when one picture is not finished, another thread cannot be displayed, at least partially. Then we will use a model called producer and consumer, English is Producer-consumer.
5. The demise of two of threads can be controlled not completely and OS, when we need to give a condition so that each thread in accordance with the condition is to perish, that is, the orderly demise, we call two-phase termination.
So with these 5 threading models, you can basically use most of the programming tasks. The three points I need to point out are:
1. At a high level we can then verify that all the cases are covered.
2. In fact, the pattern is not completely fixed or like the law, and the pattern can be adjusted and combined for different situations, in order to be concise and efficient.
3. Learning mode is to have a better ability to analyze problems.
And it seems that the technology from the West, and is present, do we have it? In fact, I personally have a bold speculation, I think our ancestors of the "Art of War" is a good design model, because it conforms to the design pattern needs of the basic characteristics of the specific conditions, in a certain way reasonable and efficient solution to the problem. Only one is used in the military, the second is the completeness of the aspects we have not studied. But I think we are at least not very good at expanding and using analogical application, otherwise today may be we Chinese teach foreigners what is the design pattern.
The method of analogy is actually a common method of invention or discovery. I wonder if I can make you feel that foreign technology is not so mysterious, maybe we have to dig out of our own culture is too little.
P.S. Further research you can refer to Doug Lea <<concurrent programming in Java>>

Related Article

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.