Modern computers can have several processors or several cores in one processor and this offers big opportunities in developing applications. Because traditionally, applications have been developed for consecutive computation and as result to solve many complex problems you had to spend more time, money and other resources. Nowadays such programming languages as Java provides all necessary tools to make a multithreaded application.
Let’s get started from basics and go ahead for more complex things like Java concurrent package, but we will do it serially. Continue reading Java Concurrency Overview Part 1
Unlike C++, Java automatically allocates and deallocates memory so the applications don’t have to do it by its own. But, the way how garbage collection works depends on JVM implementation. In this article I will talk about HotSpot JVM, since it is commonly used in production.
In HotSpot JVM the heap is separated into the generations basing on weak generational hypothesis because empirical analysis of applications has shown that most objects have short life-cycle and there are few old-to-young references. Therefore, the heap is separated into young generation and old generation. This segregation helps to keep a big bunch of dead objects in one place that can be collected very quickly. At the same time the young generation separated into three spaces eden, survivor 0 and survivor 1.
The perm space is the method area that contains information on methods, classes, method’s code etc. One of the biggest improvements in Java 8 is that perm space is removed from the heap. Since in earlier versions if your application loads a lot of classes then you had to tune and optimize this part of the heap. Another interesting improvement is string deduplication it searches for strings which occured more than once and replaces them to pointer that references to a string.
Continue reading Garbage Collection in Java
When we are talking about Java Virtual Machine we can think of three different things: specification, implementation or instance of the JVM. Lets have a look at these things in more details. The specification describes abstract concept without any implementation details to keep interoperability. Basing on the specification we can create implementation for almost all platforms. Thus, the same Java byte code can be executed on Windows or Linux. The difference between implementations is not only based on the platform, some JVM implementations can differ by performance, vendor or by additional functionality. To run Java application we need an instance of JVM implementation. The new instance is created every time the application started and instance is destroyed when application completed. So – if we run three applications then three instances will be created.
Basically, by the specification, the Java virtual machine is described in terms of subsystems, runtime area etc:
Continue reading Introduction into Java Virtual Machine
If you are a Java developer and you are going to achieve success in Java, it is very important to have clear understanding and know difference between main Java components . This knowledge will give you overall picture of what Java is, how it works and definitely will help you in developing applications.
Firstly, I would like to show you all main components in one diagram. On the diagram below you will find information on how the components related to each other and which components are parts of other components.
For instance, you can see that Java Development Kit JDK includes all components . The Java Virtual Machine JVM includes Just-In-Time compiler JIT and core libraries. In fact, you can install only JRE without development tools, but in this case you will not be able to compile Java code to byte code. Continue reading Difference between JDK, JVM, JRE, OpenJDK and JIT