Summary
In addition to running multiple threads within one application, many use-cases call for running multiple applications inside a single JVM. Such JVM-level multi-tasking is important not only in mobile applications where resources are at a premium, but also on the desktop and the server. Mark Lam provides an implementor's view of Java multi-tasking.
Advertisement
The ability to execute multiple concurrent threads within a Java program has been possible since Java 1.0. However, multi-threading within an application is different from multi-tasking—the ability to execute concurrently running Java applications within the same JVM.
Concurrent program execution within a JVM is important in resource-constrained mobile devices, where a single JVM would have to run multiple midlets or even multiple applications within a small memory footprint.
However, recent trends indicate that such JVM-level multitasking may become common on the desktop and the server as well. For instance, some JVM implementations, such as some by Apple, facilitate quick application launching by loading new Java applications into an already-running JVM.
On the server, an InternetNews.com article, BEA To Shift Into Virtualization Software, last week pointed to BEA's new initiative, the WebLogic Server Virtual Edition (WLS-VE) 1.0, a Java EE server that will bypass a traditional operating system and will instead run directly on a hypervisor, or a virtual-machine monitor. Such systems will require that a single JVM execute multiple Java applications.
While multi-tasking gives greater control over Java applications to a JVM implementor, it is also much more complex to implement, and thus is expected to be supported only in a limited fashion, according to a recent blog post by Mark Lam, Multi-tasking the Java platform: What's the Big Deal?.
Lam points to four areas that a JVM will need to support to provide true multi-tasking. He compares these to how operating systems support multi-tasking:
Concurrency: Multiple applications can run on the same device at the same time. The OS may also ensure fair allocation of resources between the applications.
Isolation: Each application has its own VM environment. An application must not be able to interfere with other concurrently running apps, and vice versa. Bugs and misbehaviors are quarantined in the bad app's environment.
Reliable Termination: When an application misbehaves, the application manager must be able to terminate the bad applications and reclaim its resources reliably.
Efficiency: Reduce redundancy in resource usage and maximize sharing between applications. Also, reduce redundancy in initialization time of the Java VM for each application.
Lam points out that several of those goals are defined also in JSR 121, the Application Isolation API. That API attempts to define a compartmentalized JVM environment that will let multiple applications co-exist in the same VM.
Since JVM startup time and VM memory use are among the biggest outstanding complaints about Java performance, to what extent do you think a multi-tasking Java environment is important on the desktop and on the server?
...in other words, Java is to become a fully fledged operating system...no surprise there, becoming an O/S is the final stage for any software before its death...
> ...in other words, Java is to become a fully fledged > operating system...no surprise there, becoming an O/S is > the final stage for any software before its death...
> ...in other words, Java is to become a fully fledged > operating system...no surprise there, becoming an O/S is > the final stage for any software before its death...
Actually, the point of the original blog was that implementing multi-tasking is not trivial, and therefore OS-type multi-tasking will not likely happen. Also, OSs are about much more than just multi-tasking. But some form of multi-tasking for the VM is really useful - even on the desktop, many people would prefer a single JVM that shares its static resources between various Java apps to having to start up a VM for every single application on one host.