Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You just use your custom thread instead of 'main', so there is no improvment. There is no 'multi' threading in your example.</p> <p>If you want to see speed improvment, you should run several thread simultaniously. Use some sort of thread pool for concurrent task processing, and then you will get improvment.</p> <p>Also, variable must be final, because you are creating anonymous class - Runnable. You should create new class wich will implements Runnable and pass into constructor your variable.</p> <pre><code>class QueryTask implements Runnable { private final List queryList; public QueryTask(List queryList) { this.queryList = queryList; } @Override public void run() { try { //writing the updated data in DB aggregationDAO.updateCaseDetailsInOracle(queryList); } catch (Exception e) { throw new RuntimeException(); } } } </code></pre> <p><strong>USAGE:</strong></p> <pre><code>final ExecutorService threadPool = Executors.newCachedThreadPool(); threadPool.submit(new QueryTask(queryList.subList(0, 5))); threadPool.submit(new QueryTask(queryList.subList(6, 10))); </code></pre> <p>This will process your queryList by portions concurrently.</p> <p><strong>UPDATE:</strong></p> <p>When you already submit all your tasks, you can shutdown threadPool and wait while all tasks will be done. You can not add any new task after that.</p> <pre><code> threadPool.shutdown(); try { threadPool.awaitTermination(10, TimeUnit.MINUTES); } catch (InterruptedException e) { // Current thread was interrupted. final List&lt;Runnable&gt; runnables = threadPool.shutdownNow(); System.out.println("Can't stop tasks: " + runnables.size()); // Restore interrupted status. Thread.currentThread().interrupt(); } </code></pre>
 

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