开发者

Java Multithread

Can One JVM handle multiple JVM ? As One JVM ha开发者_Python百科ndles Multiple Threads, So I mean to ask That can one JVM handle multiple JVM treating them as thread? If Possible Please share with me the soln and example as well


You can use Runtime.exec to launch external processes, which could easily be a Java execution. Then you'd have a handle to the process running in another JVM, and you could interact with it (by sending it "console" input and reading its output) from a thread.

However, in this case the second JVM wouldn't be running inside the first, but merely alongside it with the two able to communicate via streams. Depending on what you're looking for this may or may not suffice.

Perhaps if you gave an example of whatyou're trying to achieve? I can't think of any reason you'd actually need nested JVMs, so I don't think you're asking your real question.

Edit: What you are trying to do sounds like a recipe for disaster. If you want to speed up your application, use a profiler such as JProfiler, identify the areas where your application spends a lot of its time, and look at ways to define those areas more efficiently.

If you write good, clean code the JVM (in conjunction with the underlying OS) will execute it efficiently for you.

Your question implies a misunderstanding of the general principles of how to improve a program's performance; it's like using a screwdriver with the wrong size head, then going off to get a pneumatic drill because the screw won't go in. It will not work, and it will end in disaster.

(Does anyone know of a good "first steps in performance tuning Java" tutorial that could be linked here? Thanks.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜