Process, thread and JVM, CLR

Source: Internet
Author: User
Tags dashed line

Relationship of process and thread:

There is a very classic diagram on the web that allows us to understand the relationship between processes and threads:

The following diagram is a two-way multi-lane road map, and if we look at the whole road as a "process", then each lane separated by a white dashed line in the figure is the "thread" in the process.

This picture is from: http://www.blogjava.net/pengpenglin/archive/2008/09/02/226292.html

Some notes:

    • These threads (lanes) share common resources (land resources) for processes (roads).

    • These threads (lanes) must be dependent on the process (road), that is, the thread cannot be separated from the process (as if it were out of the way, the lane would be meaningless).

    • These threads (lanes) can be executed concurrently (each lane you walk, I walk my), or you can sync with each other (some lanes are forbidden to move on or turn when the traffic lights are on, and must wait for the other lanes to pass).

    • These threads (lanes) rely on code logic (traffic lights) to control the operation, and once the code logic is incorrectly controlled (deadlock, multiple threads compete for the only resource at the same time), then the thread will fall into chaos and disorder.

    • These threads (lanes) between who run first is unknown, only the moment the thread is assigned to the CPU time slice (traffic light change) can be known.

Lifetime of the thread

When a thread is scheduled to execute, the thread undergoes several states, including: Not started, activated, sleep state, etc., such as the lifetime of the displayed thread:

This image is from the C # Threading Reference Manual, the electronic version of this book is available in CSDN: http://d.download.csdn.net/down/1493065/phs415

If you use Java, it's easier to see the diagram below, in fact they describe exactly the same things:

JVM with process, thread

Java-written programs run in the Java Virtual Machine (JVM), and each Java application starts with Java commands, and a JVM process is started. In the same JVM process, there is only one process, which is itself. In this JVM environment, all program code runs as threads. The JVM finds the entry point of the program, Main (), and then runs the main () method, which creates a thread called the main thread. When the main method finishes, the main thread runs. The JVM process also exits.

As shown in the following:

See the above information:

A brief talk on JVM and JRE
Http://blog.csdn.net/liufeng_cp/archive/2008/07/18/2674317.aspx

Java Multithreaded Programming Summary
http://lavasoft.blog.51cto.com/62575/27069

Java because of the cross-platform to consider, so it with the process, threading model is relatively simple,. Net is more complex:

. Net CLR, process, application domain, thread

Description

    • Similar to a Java virtual machine, the CLR currently exists within a process, that is, the process loads the CLR. In. NET 4.0, you can coexist. NET 4.0 and previous versions of the process, which is a typical scenario for this (. NET 4.0 new feature you: "In-proc SxS" means this).

    • The concept of application domains is introduced in. Net, which is a further logical partition within the process. Obviously: a process can contain multiple application domains, each hosting one in an application domain. NET executable program. The benefits of this:

      • The application domain is. The key features of the net platform operating system independence. This logical partitioning abstracts the differences in the execution of executable programs loaded by different operating systems.

      • The application domain has a much smaller CPU and memory footprint than a complete process. So the CLR loads and unloads the application domain much faster than the complete process.

      • Application domains provide deep isolation for hosted applications. If one of the application domains in the process fails, the other application domains will remain healthy.

The following diagram depicts where the application domain is located:

See: CLR thorough and thorough parsing of in-process parallelism

Resources:

Delve into the Java virtual machine
Http://www.chinaaspx.com/comm/dotnetbbs/Showtopic.aspx?Forum_ID=33&Id=302411&PPage=1

About process threads and some common multithreading concepts
Http://www.cnblogs.com/ChrisWang/archive/2009/09/07/1563675.html

. Net Discovery Series five--in layman's light. NET real-time compilation mechanism (top)
Http://www.cnblogs.com/isline/archive/2009/12/22/1629831.html

A brief analysis of Linux threads
http://blog.chinaunix.net/u2/87597/showart.php?id=2178432

How Azure Cloud application Run features
Http://tech.ccidnet.com/art/1105/20090625/1808497_1.html

Reading Experience-programmer-C # Threading Reference Manual (multithreading technical Analysis)
Http://www.cnblogs.com/lzhdim/archive/2009/11/27/1611510.html

Basic knowledge points of multithreaded programming
Http://www.blogjava.net/pengpenglin/archive/2008/09/02/226292.html

Java Multithreaded Programming Summary
http://lavasoft.blog.51cto.com/62575/27069



Process, thread and JVM, CLR

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.