title: Execute Java main method on a different thread with Maven
body: <p>I am converting my Ant project to a Maven project.</p>
  
  <p>In Ant I am invoking a Java class but in a different thread using <code>fork="yes"</code> option in Ant.</p>
  
  <p>Now I am trying to find a similar task in Maven.</p>
  
  <p>I have code like the following, but I'm not sure if it is correct or not. It is calling my main class as expected, but it is running in the same thread/JVM.</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
      &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.2.1&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;phase&gt;compile&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;java&lt;/goal&gt;
              &lt;/goals&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
      &lt;configuration&gt;
          &lt;mainClass&gt;com.App&lt;/mainClass&gt;
          &lt;arguments&gt;
              &lt;argument&gt;-s src/main/resources&lt;/argument&gt;
          &lt;/arguments&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>Here com.App is a class which has a main method.</p>
  
  <p>I need to run this in a different thread because the App.main() method contains a call to <code>system.exit()</code>, so the control is not coming back. As I am not authorized to change the App class, I have to call that in a different thread.</p>