I make parallel processing program using java.util.concurrent.ForkJoinPool. While proceeding this program, I checked top
and htop
, and noticed that in top
there are only one java process but in htop
there are many processes.
My senior is writing parallel processing program using python, and he says that it is strange that there are only one process in top
. And also he says that the "CPU usage" in top
is usually over 90%. But my program uses only about 68%.
I thought that the cause is the difference in how to realize parallel processing between java and python. But I do not know whether it is correct. Please tell me the correct cause of this difference.
Thanks.
Did your senior implement multiprocessing or multithreading in python? To see the difference look at Multiprocessing vs Threading Python
I'm pretty sure he is doing multiprocessing, which spawns multiple processes which are real copy instead of threads with shared memory. The behavior of top
/htop
is correct. top
only shows the processes while htop
also shows the threads.
The difference would be that you are using multithreading and your senior seems to use multiprocessing also explains the different CPU usage.
You can press H
in htop
which will toggle the view of the user threads. Now it should be nearly the same view as in top.