Five minutes to learn Java: Java to learn how to interview and tests of the JVM virtual machine

Unnamed .jpg copy _

Original Statement

Author: Huang oblique

Reprint please indicate the source and author at the beginning of the article.

This article Mind Mapping

Here Insert Picture Description

Why learn JVM virtual machine

Have you ever participated in a recent Java interview? Have you ever noticed, Java interview always love to test a class of problems that JVM virtual machine, so the interviewer why the study of love JVM problem, this was because all Java programs are essentially running on the JVM no JVM virtual machine, there is no execution environment of the Java language, only to master the relevant knowledge JVM virtual machine, you can say that you know Java, otherwise it will play like a cell phone people say that they are they do not understand Android operating the same system.

The introduction Baidu Encyclopedia, is an abbreviation for the JVM Java Virtual Machine (Java virtual machine), the JVM is a code of a computing device, which is a fictional computer, by simulations on a computer simulation of the actual various computer function to achieve. After the introduction of Java virtual machine language, Java language does not need to be recompiled to run on different platforms when. Java Virtual Machine using Java language information associated with a particular shielding platform, so that only Java language compiler to generate object code (bytecode) running in the Java virtual machine can run without modification on multiple platforms .

It is because of the presence of the JVM, Java will be able to have the ability to run cross-platform, once, run everywhere, contrast, C ++ kind of language, you need to compile everywhere to run, because it itself is a language and operating system strong association also there is no concept of a virtual machine.

Of course, because of the presence of JVM virtual machine, the complexity of the Java language is also greatly reduced, their pay is paid for by the speed has dropped, leaving the JVM Java Virtual Machine makes no sense to talk about, to learn is to learn everything JVM Java technology premise.

How to learn JVM virtual machine

JVM virtual machine on our side

The first time I heard this thing JVM virtual machine, or in a face questions in, then I do not know if this is a hell ah, then I bought a book called JVM Bible "in-depth understanding of JVM virtual machine" was fortunate enough know, the original JVM virtual machine running on our computers.

As a Java developer, three-piece entry is probably the IDE, JDK and JRE, in fact, JDK contains the JRE, and JRE (Java Runtime Environment) also contains the JVM virtual machine. When we use or use ide javac compile the Java program execution or, in fact, the java code mutate into class bytecode, and then thrown into the JVM execution.

Our task at this time there will be a process manager, called java, this process can be understood as a JVM process, and this process there are many sub threads, are responsible for the implementation of the code, garbage collection and so on.

Many times we have no idea JVM virtual machine is Gesha, naturally, can not learn it well, once we understand its nature, things behind the learning curve will not be so painful.

On the JVM face questions

There are a lot of programmers JVM may be the first time I heard during the interview, face questions about the JVM in fact, a lot of, for example where some of the more popular interview questions, such as "JVM heap and stack What is the difference," " JVM's garbage collection algorithm which "," JVM memory model is what kind of "etc., such a title regarded as the basis of comparison.

Such topics, usually by brush by surface, it is possible to answer it, after all, the interviewer will not necessarily know more than you, so the interviewer may not dig deep down. But if some of the technical investigation was more in-depth company is not necessarily a lot of the Java technology stack-based companies, especially electricity supplier companies, to examine the JVM is quite in-depth, in addition to Ali US group, there Jingdong, the only product with praise, fight a lot of other companies.

So, we might as well take a look at the advanced version of the JVM face questions look like. First, the advanced version of the title mainly on depth, such as JVM memory model, you must make it clear what each region is doing, and will make the actual scene to ask you, such as string variables in which area metadata based on which region of the local and global variables and which regions are placed. If you're only vaguely aware memory model, all of a sudden it will be seen through to the interviewer.

Advanced version of the JVM interview also like to examine the details, such as the JVM garbage collection algorithm, stop copying, mark clear, you need to clear process, the respective advantages and disadvantages clear. If this problem is not a threat to you enough, it may wish to look at other kinds of questions JVM garbage collection, "How is the young generation GC, please explain in detail the process" A lot of the interviewer might put it simply about the young generation the recovery methods.

You might simply replied: "use of stop copying done" In fact, in fact, there can tell there are a lot of details, first of all, the young generation is divided into zones eden and survivor district, survivor is also divided into zones and from to district, eden region will be put objects surviving from area, but after the next young gc, from region to region and will swap positions, the object will follow the move, so the age of the object plus one, when the object over the age of when the threshold value, the object will enter the old era.

Seemingly simple question can actually know the result of so many doorways, and this is my experience was summed up many times after the interview experience.

JVM Bible "in-depth understanding of JVM virtual machine"

Thousands and thousands of Java books, but it can really make it clear JVM virtual machine may book only this one up. Most online blog about the JVM is basically learn the content or reference book.

Then this book in the end say what the contents of some of the JVM, and I wish to work together to disassemble it.

The first part of this book is about the history of the language Java, and why it should run on the JVM, which is very important, otherwise developers will wonder why good programming language to run it on a virtual machine .

The second part, the book began to introduce the core concepts of the JVM that memory model, JVM is how to manage the computer's memory, but also how to divide these areas, after all, in Java types and variables so much, really bad management.

The third part is the more difficult part of this book, it begins to introduce the principle of running Java code, that is to put java code is compiled into byte code before you can perform on the JVM, Java code while in turn one by one classes, so the article describes how to JVM virtual machine load these classes, and there are many novel concept, it is worth exploring.

The fourth part, compile and code optimization, this part is actually more popular, but it is actually quite complex, there is mentioned a lot JVM optimized for program execution, including optimized compile and run the optimization, optimization the purpose is to make Java programs run more efficiently, understand this part after, you will certainly JVM virtual machine designed to produce reverence.

The fifth part focuses on the JVM Java support multithreading, Java multithreaded nature also based on the JVM designed and implemented, which will involve our common locks, here introduced are synchronized, it is the essence of mutex, but as the JVM optimized for heavyweight lock synchronized, it gradually began to support lightweight locks and lock bias.

It can be said, are the essence of the whole book, basically focusing on exam examination, of course, there are some elements of the more popular, less affected by the interviewer to be seen. But this book is basically the JVM where we need to have clear knowledge, and for the JVM theoretical study, this book is enough.

JVM tuning combat

Finished theory, and finally to the part of the combat.
JVM overall knowledge module appears to be a partial theory of knowledge, not much seems to be able to practice things, but in fact, be able to practice aspects of the JVM can be a lot of things, such as the JVM tuning, GC analysis and JVM memory analysis, are interview official liked the ability to examine the practice.
The next section, we will say something about the actual content of the JVM.

In some advanced Java interview, questions about the JVM might relate to JVM tuning and practice, such as you have never met before OOM or a memory leak, how did you find them, or, GC too often, how should we conduct the investigation.
In short, these questions are based on practice, practice is the study of the candidate's experience, which usually have been for CRUD, and even how the server did not come across friends, is indeed a big challenge.

That we supposed to do, in fact, is not no way, after all, I'm a white JVM no practical experience, before I review in this regard mainly through several methods.

Find some of the more well-known JVM tuning tools, try, such as Jprofile, also comes with the JDK jmap jstack and so on. These tools are used to test for its own program, write a few oom or memory leaks, and see what happens in the tool will appear, and this is one good way of learning.

But someone will say, face a lot of questions are high and have high load or scene, usually their own code would not face this problem, then how to do it, in fact, there are ways for such online tuning in fact face questions there are a lot to share, for a certain scene how to tune, what steps should be, in fact, can be found some of the answers from someone else's article, so even if you do not usually work this type of practice, you can learn by excellent tune JVM actual article to review, in fact, the truth is the same.

Recommended Resources

books

"In-depth understanding of JVM virtual machine"

video

I compiled some aspects of the JVM learning video for everyone to share, in fact, this area is not much video resources, after all, most video or speak or project-oriented basis, be able to thoroughly publicize the JVM virtual machine does not much talk about good people .

Blog

Java technology storehouse "Java Programmer's Guide review"
https://github.com/h2pl/Java-Tutorial
integration of the whole network of high-quality Java learning content, to help you from basic to advanced Java systematic review

Interview Guide

The whole network hottest Java Interview Guide, a total of more than 200 pages, very practical, whether for review or preparing for interviews are good.

to sum up

Learn about how JVM virtual machine, and get the relevant interview questions, we talked about here today, and if there are any questions I can also go to the public No. [programmers] Huang inclined to explore where to find me, follow-up there will be more articles launched, including how to systematically learn JavaWeb, so stay tuned.

Yes, I would like to ask you in books and articles mentioned in the video where to find? I have given you ready

Resources mentioned in the text can receive free, in my public No. [programmers] Huang oblique reply "Java Concurrent Programming" to receive a free corresponding resources.

Written in the last

If you think this article helpful to you, you do not mean your "nice" Ha, forward circle of friends is my greatest support you, your support is my greatest encouragement.

Any suggestions and comments on this series of articles, comments are also welcome to tell me, look forward to your feedback.

Published 293 original articles · won praise 1597 · Views 1.23 million +

Guess you like

Origin blog.csdn.net/a724888/article/details/104932471