我目前正在使用ant运行java进程。我只运行一个进程。
当我使用htop时,我看到以下信息:
向右滚动给出:
基本上,中间部分由只是我的java进程组成。
当我ps aux | grep java
时,我看到了:
$ ps aux | grep java
victor 27982 1.0 1.9 3799504 163112 pts/1 Sl+ 02:00 0:06 /usr/bin/java -classpath /usr/share/ant/lib/ant-launcher.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/xercesImpl.jar -Dant.home=/usr/share/ant -Dant.library.dir=/usr/share/ant/lib org.apache.tools.ant.launch.Launcher -cp tag
victor 28003 19.0 6.6 3523136 544812 pts/1 Sl+ 02:00 1:51 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java -Xmx2048m -classpath /home/victor/Giordano/java/lib/commons-math3-3.0.jar:/home/victor/Giordano/java/lib/guava-14.0.1.jar:/home/victor/Giordano/java/lib/joda-time-2.2.jar:/home/victor/Giordano/java/lib/postgresql-9.2-1002.jdbc4.jar -jar /home/victor/Giordano/java/build/jar/Giordano.jar 15
victor 28135 0.0 0.0 9388 924 pts/3 R+ 02:10 0:00 grep --color=auto java
知道为什么我的进程在htop中有这么多实例?
仅供参考我在四核机器上运行。
如果您有兴趣,这是我的构建文件。
<project name="Giordano" basedir="." default="main">
<!-- Keep Eclipse's bin away from our build, use separate folder -->
<property name="build.dir" value="build" />
<property name="src.dir" value="src" />
<property name="lib.dir" value="lib" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="jar.dir" value="${build.dir}/jar" />
<!-- Main Classes for different processes -->
<property name="like.main.class" value="com.crowdy.learn.SimilarityLike" />
<property name="model.main.class" value="com.crowdy.learn.SimilarityModel" />
<property name="tag.main.class" value="com.crowdy.learn.SimilarityTag" />
<path id="lib.path">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="compile">
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}">
<classpath refid="lib.path" />
</javac>
</target>
<target name="main">
<echo>ant is not defined. Use ant like, ant tag or ant model.</echo>
</target>
<!-- Running Like -->
<target name="like" depends="clean,like.run" />
<!-- Ant properties are not mutable.
So if we have -Ddb=xyz passed in via cmd line then this will not be defined. -->
<property name="simThreshold" value="0.05"/>
<property name="minFeedback" value="40"/>
<target name="like.jar" depends="compile">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${like.main.class}" />
</manifest>
<fileset dir="${classes.dir}" includes="**/*.class" />
<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />
</jar>
</target>
<target name="like.run" depends="like.jar">
<echo>SETTING parameter simThreshold to ${simThreshold}</echo>
<echo>SETTING parameter minFeedback to ${minFeedback}</echo>
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true" maxmemory="1024m">
<classpath refid="lib.path" />
<arg value="${simThreshold}" />
<arg value="${minFeedback}" />
</java>
</target>
<!-- Running Model -->
<target name="model" depends="clean,model.run" />
<property name="minFeedbackCount" value="15"/>
<target name="model.jar" depends="compile">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${model.main.class}" />
</manifest>
<fileset dir="${classes.dir}" includes="**/*.class" />
<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />
</jar>
</target>
<target name="model.run" depends="model.jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true" maxmemory="1024m">
<classpath refid="lib.path" />
<arg value="${minFeedbackCount}" />
</java>
</target>
<!-- Running Tag -->
<target name="tag" depends="clean,tag.run" />
<property name="minTagCount" value="20"/>
<target name="tag.jar" depends="compile">
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${tag.main.class}" />
</manifest>
<fileset dir="${classes.dir}" includes="**/*.class" />
<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />
</jar>
</target>
<target name="tag.run" depends="tag.jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true" maxmemory="1024m">
<classpath refid="lib.path" />
<arg value="${minTagCount}" />
</java>
</target>
</project>
答案 0 :(得分:10)
Htop也显示了线程。我认为所有这些进程都是由您的应用程序创建的线程。如果您不想看到它们,请按shift + H.
答案 1 :(得分:0)
使用fork attribute
中的java task
打开一个新的Java Process / VM,参见
Ant manual java task:
..“
if enabled triggers the class execution in another VM (disabled by default)
..“
这意味着每个fork = true都会打开一个新的java进程。