Init Jvm with smallest possible threads

I have a simple java

hello world program withsleep

Java code:

    public class Main {
    public static void main(String[] args) throws InterruptedException {
        Thread.sleep(100000l);
     }
   }

      

compile with javac

javac Main.java

      

Run with

java Main

      

Now if I see in jvisualvm

, I can see this 11 threads.
Why does the RMI thread start?
How do I start jvm with important threads only?

why i want to do this because the limit is limited nproc

in limit.conf

and need to run maximun jvm at the same time. Also these jvm live short.

I am using oracle jdk 7

enter image description here

+3


source to share


3 answers


Would you believe me if I told you that none of these streams really mean anything to you?

They are all either part of the infrastructure that VisualVM uses to talk to your program or part of the JVM itself. None of them can be safely eliminated, nor can they; they do VM background tasks, so you don't need to worry about them.



Basically, don't worry about it, the overhead they give in programs much larger than hi-world is pointless.

If you're wondering what these pair are, it reference manager

just manages the objects currently in memory and finalizer

is part of the garbage collector. In short, things you shouldn't worry about.

+2


source


See Is there a way to completely disable RMI in a Java application?



If you are not using RMI, your JVM does not start RMI threads. "Short-lived" JVMs are most likely not an idea that will work well with or without the measurable overhead of RMI threads.

+1


source


RMI streams are launched on demand only when connected to the JVM using VisualVM, JConsole, or a similar tool. As for other threads, there is another answer on how to reduce their number.

+1


source







All Articles