Android - How to Run Multiple Threads in Parallel
<p>I am developing an android application that synchronizes the user's emails using Gmail API. </p>

<p>To do so i have implemented two services where the first is for downloading the Unread Emails and the second is for downloading Read Emails. Each service implements the Runnable interface and the code for retrieving the emails and storing them in the database is handled using a thread inside the Run() method.</p>

<p>Everything works fine the only problem i have is that when the Thread responsible for downloading the Read Emails is running (which takes longer than the other) the second Thread (Sync unread emails) is blocked until the first one is completed.</p>

<p>I would like to know if there is anyway that i can prioritize the second Thread over the first one so whenever the first one is running and the second thread have to run, the code should put the second thread on hold until the first one (Unread emails) complete running and then resume the thread on hold.</p>

<p>Regards.</p>