This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
One JVM can run as many threads as you like. There are lots of way that they can share data, such as classes with global (public static) data, using a SQL database, files, sockets, RMI, CORBA.
The following is not beginner material, but for completeness...
The java(.exe) executable is by far the most common way to run a Java application, but not the only one. What it does is it creates a JVM, locates the class specified on the command line, finds the static main() method in that and tells the JVM to run that. This all happens essentially on one thread, but main() may create as many more threads as it likes.
It is possible to write your own native executable program to create a JVM and run Java on it. This would use the Invocation API from the Java Native Interface. You could make that load multiple classes, create additional threads and run the main() or other methods of those classes on those threads.
I strongly suspect that's not what you want, though. You probably just need to write a "wrapper" class with a main() method that fires off the main() methods of various classes, in separate threads. [ January 31, 2005: Message edited by: Peter Chase ]
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Jan 31, 2005
Thanks for this. I was bit confused for how can JVM will handle multithreads. I mean may be the out put we require as a graph as well as data at same time.
Joined: Oct 30, 2001
If what you actually want is a tutorial on threads, try this or search JavaRanch.