search

Home  >  Q&A  >  body text

java - 熟悉JVM对编程有哪方面好处?如何更好地理解JMM?需要结合哪些知识点去理解,需要做哪方面的实践去加深理解?

一直不是很理解JVM主要应用于哪些技术开发,最近看周志明的《深入理解Java虚拟机》是源于自己想加深对Java的了解,以便为春招找份好的工作(主要是找Android开发方面的)……这本书除了前几章将JVM历史、内存管理机制、类加载方面比较好理解,看到后面就比较难理解了,特别是程序编译和代码优化、JMM和线程安全与锁优化的,就比较羞涩难懂了……如果以后只是想往Android方面发展,需要对JVM了解多深?

PHPzPHPz2769 days ago914

reply all(2)I'll reply

  • 高洛峰

    高洛峰2017-04-17 12:11:05

    If you just want to develop in Android in the future, how deep do you need to know about JVM?

    Asking this question is a bit superficial (not in a derogatory sense).

    If you want to study JVM in depth, yes, it is worth encouraging.

    As an industrial-grade operating platform, JVM is indeed excellent and worth studying. However, JVM is not everything. If you want to improve yourself, you cannot limit yourself.

    You can study compilation principles, computer architecture, algorithms and data structures, computer graphics...

    Expand your thinking.

    The question now is not how deeply you need to understand the JVM, and if you only study the JVM, you will not study too deeply at all. Just like what you described, it is more difficult to understand after seeing the program compilation and code optimization, JMM, thread safety and lock optimization . It does not mean that you have not learned Java well, but that you are just too thin in other aspects. .

    Secondly, it’s not about how much you learn, but how much you use it.

    (PS: Advertising break, my new book "The Mystery of Code" will have many chapters introducing the unconventional use of code ideas)

    Give me an example:

    You are developing a network disk system or a picture bed system. In these systems, in order to improve efficiency, there will be a Miaozhuan function. That is: when a file already exists on the server, there is no need to upload it again.

    When A uploads a file, such as XXX老师高清无码1080p.rmvb, this file is so popular that not only A, but also other otakus B C D have uploaded this file. However, B C D does not need to be re-uploaded again, just point to this file.

    The above is all nonsense, even a programmer understands it.

    Now the question comes, how to handle the user’s deletion operation?

    Now we want to implement such a function. If A B C D all delete this file, then we will delete this file on the server. However, if no one among A B C D deletes the file, the file will remain on the server.

    Read the above words a few times to see if they are particularly familiar to you.

    Yes, it is GC. Therefore, we can figure out when this file is deleted, when it is retained, how to make it efficient, and how to achieve good concurrency by studying the JVM's GC algorithm.

    The example is a little inappropriate, just to clarify the problem.

    GC algorithm is not limited to GC.

    Don’t let knowledge constrain your thinking.

    reply
    0
  • 阿神

    阿神2017-04-17 12:11:05

    If you just want to develop in Android in the future, you may not need a particularly in-depth understanding.
    However, as you deepen your use of Java, it will come naturally to you to understand parts such as program compilation and code optimization that you may still find difficult to understand.

    reply
    0
  • Cancelreply