Question

i run my program using maven with the following command:

mvn exec:java -Dexec.mainClass="some.path.to.my.class"

on a Linux multi-cpu server. when i check the CPU usage, i see that java eats only 1 CPU core. i read somewhere that setting the -server parameter could help.

what parameters do i have to set and how can i pass them using the mvn exec:java command?

Was it helpful?

Solution

You would set it in the commandlineArgs section of the configuration in your pom, as described in the documentation

eg:

 <build>
<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
      <execution>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>maven</executable>
      <commandlineArgs>-server</commandlineArgs>
    </configuration>
  </plugin>
</plugins>

Although I'm not at all sure this is your problem - have you definitely written multithreaded code? You don't need to run the JVM in server mode to use multiple threads.

OTHER TIPS

Processor affinity allows you to bind threads or processes to specific CPU cores.  Java doesn’t have native support for processor affinity but we can set a process affinity using the taskset command. Say we have a Java process running and we want to pin it to a specific CPU. please see following links for more details and find how do this: cpu pinning java

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top