title: How to calculate the running time of my multithreaded program
body: <p>I am trying to calculate taken my all the thread created by my program in total but my code is calculating the time only for invoking.</p>
  
  <p>I am sure because in the output i see difference printed before all the threads are finished</p>
  
  <p>below is my main program RequestProcessor here is my thread class</p>
  
  <pre><code>int i = 0;
  List&lt;Customer&gt;customers = customer.getCustomers();
  long startTimestamp = System.currentTimeMillis();
  for (Customer c: customers){
      new RequestProcessor(c, i).start();
      i++;
  }
  long endTimestamp = System.currentTimeMillis();
  System.out.println("difference  = "+(endTimestamp - startTimestamp));
  </code></pre>
  
  <p>below is the Request Processor class</p>
  
  <pre><code>public RequestProcessor( Customer customer , int threadSeq ) {
      super();
      this.customer = customer;
      this.threadSeq = threadSeq;
  }
  
  @Override
  public void run() {
      // TODO Auto-generated method stub
      processRequest();
      super.run();
  }
  
  public void processRequest(){
      //performing execution on customer here
      System.out.println("processing "+ customer.getName()+" thread seq "+threadSeq);
  }
  </code></pre>
  
  <p>below is the the output that I am getting </p>
  
  <pre><code>processing customer9 thread seq 9
  processing customer7 thread seq 7
  difference  = 4
  processing customer3 thread seq 3
  processing customer2 thread seq 2
  </code></pre>
  
  <p>I tried using join but didn't work for me</p>