Reputation: 4177
I have a simple java
hello world program with a sleep
Java Code:
public class Main {
public static void main(String[] args) throws InterruptedException {
Thread.sleep(100000l);
}
}
compile using javac
javac Main.java
Run using
java Main
Now if i see in jvisualvm
i see this 11 threads.
Why are RMI thread started ?
How do i start a jvm with only the essential threads ?
why i want to do this is because constraint by the nproc
limit in limit.conf
and want to run maximun jvm concurrently. Also these jvm are short live.
i am using oracle jdk 7
Upvotes: 3
Views: 96
Reputation: 98284
RMI threads are started on demand only when you connect to JVM with VisualVM, JConsole or a similar tool. As to other threads, there is another answer how to reduce their number.
Upvotes: 1
Reputation: 2729
See Is there a way to completely disable RMI in a java application?
Unless you use RMI, your JVM will not start RMI threads. 'Short lived' JVMs, though, is probably not an idea that will work out well, with or without the perceived overhead of RMI threads
Upvotes: 1
Reputation: 365
Would you believe me if I told you none of those threads really mean anything to you?
They're all either part of the infrastructure VisualVM uses to talk to your program, or part of the JVM itself. None of them can be eliminated safely, nor should they; they're doing VM background tasks so you needn't worry about them.
Basically, don't worry about it, the overhead they give in programs much larger than a hello-world are meaningless.
If you're curious as to what a couple of them are, the reference manager
simply manages the objects currently in memory, and the finalizer
is part of the garbage collector. In short, things you shouldn't worry about.
Upvotes: 2