title: How to run CPU intensive parallel tasks with Vert.X in Java
body: <p>I want to run  run CPU intensive parallel tasks in Java, but to avoid the complicated debugging of race conditions, I decided to try an <strong>asynchronous program model</strong>. I have experience with Node.JS, I know how asynchronous stuff works and I understand the event loop. I think I don't understand the <a href="http://vertx.io/manual.html#worker-verticles" rel="nofollow">Worker Verticles in Vert.x</a> .</p>
  
  <p>Imagine the following Java code that has 3 CPU intensive processes (method slowProcess()). </p>
  
  <ul>
  <li>How can I compute a, b and c parallelly?</li>
  <li>Is the asynchronous model suitable for this, or should I use normal thread?</li>
  <li><p>Is the asynchronous model only made for I/O operations?</p>
  
  <pre><code>public class Race {
  public static void main(String[] args) throws Exception 
  {
      long a=0, b=0, c=0;
  
      System.out.print("starting ... ");
  
      //start the race
      // these 3 things should run in parallel
      a = slowProcess(a);
      b = slowProcess(b);
      c = slowProcess(c);
  
      // this should run after the 3 processes are finished
      long result =evaluate (a,b,c);
  
      System.out.print("finished : "+result);
  
  }
  
  private static long evaluate(long a, long b, long c) {
      return a+b+c;
  }
  
  private static long slowProcess(long value) {
      for (int j = 0; j &lt; 200000; j++)
      for (int i = 0; i &lt; 200000; i++)
      {
          value++;            
      }
      return value;
  }
  }
  </code></pre></li>
  </ul>
  
  <p><strong>Update/note</strong>: This is a simplified example. For these 3 processes and the simple result handling, Thread joining would be better. The real problem is more complex. I'm only wondering if someone can translate this code into an asynchronised version, or tell me why it should not be done with high CPU load processes, since they block the event queue (I think).</p>