I run a very simple, single-threaded java program. When I check the threads using command under Ubuntu
ps -eLf
it shows there are 14 threads at OS level. I expect there is only one thread when the program has one thread, and x threads if the program has x threads. Is my expectation wrong?
The JVM has its own threads, such as the garbage collector. Try doing a kill -3 <pid>
on it, and it will show you all the threads.
The JVM has multiple threads running. That is the reason why you see so many threads.
I believe the Java Virtual Machine always opens up multiple OS threads whenever it starts up, which is why you are seeing what you are seeing. Also, I'm not sure that the Java Thread class uses native threads.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With