Null pointer exception when using Runnables
<p>I am trying to connect to a website and get the links.</p>

<pre><code>Handler han=new Handler();
Runnable run=new Runnable() {
  public void run() {
    try {
      Log.e("This","I am in");
      doc = Jsoup.connect("someurl which is tested").get();
    }
    catch (IOException e) {
      Log.e("This","I am in exception");
      e.printStackTrace();
    }
  }
};
han.post(run);
Elements links = doc.select("a[href]");
</code></pre>

<p>The elements part keeps throwing a null pointer exception. I don't understand why. I have declared Document doc at the top of the class. Neither of the logs are being printed. Which means <code>han.post(run)</code> is not calling it immediately. How do I make sure that only after the <code>run()</code> completes I can access links?</p>
