Your own programs are not the only places where threads come into play. The Java runtime system actually employs threads to perform a variety of different tasks.
These background threads are executed in the runtime system alongside any of your program threads that are executing.
System background threads perform tasks such as listening for keyboard and mouse input and throwing away objects that are taking up space in memory via garbage collection.
Every Java application has a single instance of class Runtime that allows the application to interface with the environment
in which the application is running. The current runtime can be obtained from the getRuntime method.
An application cannot create its own instance of this class.
The Java virtual machine (JVM) provides a virtualized execution environment for Java applications.
To maintain safety and efficiency of the execution environment, the JVM employs some major runtime sub-systems such as
- garbage collection,
- just-in-time compilation and
- lock management.
Recent work found that the runtime overheads increase significantly when the workload of Java applications increase.
To solve this problem, industry researchers have developed various approaches of utilizing Virtual Machine-OS-hardware interactions to improve Java runtime performance.
To reduce overhead of Java runtime systems, some techniques have been implemented inside Java virtual machines to tune performance through utilizing runtime information.
For example:
- Method invocation information has been used by the VMs to select the complexity of dynamic compilation optimizations.
- Heap usage information can be used for dynamically resizing heap to reduce the frequency of garbage collections.
However, the above traditional approaches have limited power of improving virtual machine performance.
To support highly scalable and efficient Java application servers, a new technology trend has emerged which makes
Java virtual machine interact with operating systems and hardware supports to improve efficiency of runtime systems.
Similarly, there are some other research efforts to improve Java virtual machine performance by making operating systems aware of virtual machine runtime activities.
Recently, there has been work on utilizing OS and architecutal support to reduce Java runtime overheads.