title: Concurrent execution of UPDATE statements in java
body: <p>I have a list of objects for which I submit an update DB statement as below.</p>
  <p>Current code:</p>
  <pre><code>List&lt;MyObj&gt; updateObj = ....&lt;logic here&gt;;
  updateObj.stream().forEach(obj -&gt; updateMyDB(obj));
  </code></pre>
  <p>Here each obj is getting executed sequentially and taking more time. Now I wish to parallelize it. What is the best way to do this?</p>
  <p>Option 1:</p>
  <pre><code>updateObj.parallelStream().foreach(obj-&gt;updateMyObj(obj));
  </code></pre>
  <p>Option 2:</p>
  <pre><code>ExecutorService executor = new FixedThreaadPool(10);
  updateObj.stream().foreach(obj -&gt; completableFuture.runAsync(()-&gt; updateMyObj(obj),executor));
  </code></pre>
  <p>Intention here is to parallize operations. Any ideas to achieve this?</p>