Make sure both threads finish execution before executing a piece of code
<p>I need to execute a piece of code when two conditions have been met.</p>

<ol>
<li>Subject text is successfully queried from the database using background thread.</li>
<li>The dimension of View is retrieved successfully using main thread.
Both Subject text and dimension of View are stored as Activity's member variable.</li>
</ol>

<p>For 1), I simply start an AsyncTask in Activity's onCreate() and in doInBackground I query DB to get Subject text and store it in Activity's member variable.</p>

<p>For 2), I posted a Runnable to the UI thread, and in run(), I query view's dimension and store it in Activity's member variable. Done in onCreate() also.</p>

<p>It is not possible to guarantee which one (1 or 2) will finish first.</p>

<p>Therefore my question is, what is the recommended pattern to wait for both 1 and 2 to finish
before executing a piece of code?</p>
