title: Running two independent tasks simultaneously using threads
body: <p>I've studied lots of tutorials on threads in java but I'm unable to find my answer.  </p>
  
  <p>My question is: how to run two independent threads simultaneously?  </p>
  
  <p>My case is: I have two tasks; </p>
  
  <ol>
  <li>save some data to the database</li>
  <li>send a push notification on a mobile device.  </li>
  </ol>
  
  <p>Since these two tasks are independent I want to execute them simultaneously.  </p>
  
  <p>I tried using a thread pool with two threads but the problem is that the database tasks finishes quickly but it takes some time to send a push notification.  </p>
  
  <p>Consequently when one task is finished while the other is still pending, it throws an exception.  </p>
  
  <p>Also there is no problem in my code because it runs fine without using threads.  </p>
  
  <p>Thanks in advance</p>