title: Using more than one thread in Java
body: <p>I'm new to concurrent programing and have been working on code which has a queue of items to be processed, this is passed to some worker threads, the number specified by the user. At the moment I've just tried to do it with two worker threads plus the main.</p>
  
  <pre><code>private static class workerThread extends Thread {
  
          workerThread(){
              super();
          }
  
  
          public void run(){
               while (!workQueue.isEmpty()) {
  
              String x = workQueue.remove();
              //System.out.println("work queue size: " + workQueue.size());
              Vector&lt;String&gt; list2 = new Vector&lt;String&gt;((Vector) table.get(x));
              list2 = process(x, list2);
              //System.out.println(list2 + "list2");
              table.put(x, list2);
  
              //System.out.println(x + "key" + "value" + vvv);
  
          }
  
          }
  </code></pre>
  
  <p>That's the thread workerthread class, I've tried to call it just by creating two new threads:</p>
  
  <pre><code>workerThread wt = new workerThread();
      workerThread wt2 = new workerThread();
      wt.start();
      wt2.start();
      try {
          wt.join();
          wt2.join();
      } catch (InterruptedException ex) {
          Logger.getLogger(includeCrawler.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  
  <p>I'm not sure if this is right, or will have any benfit due to waiting for the joins? Thanks for any help.</p>