Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy increment of newFixedThreadPool result in poor performance?
    text
    copied!<p>I'm trying to change the execution of a report and have it done in concurrency. In a 'serail mode' the execution test takes 30 seconds and when using a concurrent mode I get 27 seconds (consider that few steps must be taken in serial I'm ok with the result). </p> <p>The thing that I still don't get is this line:</p> <pre><code>ExecutorService executor = Executors.newFixedThreadPool(4); </code></pre> <p>My computer is armed with 2x2.6 Ghz Quad Core and I would expect that the execution time will decrease if the newFixedThreadPool is high (16). In reality, the more I increase the newFixedThreadPool the slower the execution. This begs the question: What am I doing wrong or what am I failing to understand?!?!</p> <p>I'm embedding 2 results screenshots from my execution.</p> <p>A. newSingleThreadExecuter - runs in 23 sec</p> <p>B. newFixedThreadPool(4) - runs in 43 sec.</p> <p>Each time I submit a 'Worker' I get system.out the currentTimeMillis and the "fatched tkt" result is milliseconds that it takes to get the data from the db. (in strategy A - it takes ~3ms and in B up to 7ms).</p> <pre><code> Stopper stopper = new Stopper(); for (Long iNum : multimap.asMap().keySet()) { List&lt;Long&gt; tickets = (List&lt;Long&gt;) multimap.get(iNum); for (Long ticketNumber : tickets) { pojoPks = getPkData(iNum); Callable&lt;PojoTicket&gt; worker = new MaxCommThread(ticketNumber, pojoPks); Future&lt;PojoTicket&gt; submit = executor.submit(worker); futures.add(submit); } } System.out.println("futurues: " +futures.size()); for (Future&lt;PojoTicket&gt; future : futures) { try { PojoTicket pojoTicket = future.get(); //do the rest here } catch (InterruptedException e) { System.out.println("----------------------&gt;InterruptedException"); } catch (ExecutionException e) { System.out.println("----------------------&gt;ExecutionException"); } } executor.shutdown(); stopper.stop(); </code></pre> <p><img src="https://i.stack.imgur.com/nqUwN.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/I3iXH.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload