title: CountDownLatch issue in android
body: <p>I am using countdownlatch as in example below. Here BackgroundDataPopulator creates an AyncTask which in turn invokes displayData in PackagePopulator. But it never happens and the activity gets stuck. What am I doing wrong here.</p>
  
  <pre><code>public class PackagePopulator implements ServerDataProcessor {
  
      private CountDownLatch counter=new CountDownLatch(1);
      String[]  packages;
  
      public void getPagesFromServer() {
          new BackgroundDataPopulator(IMgrApplication.getAppContext().getString(R.string.list),new PData(),this).execute();
  
      }
  
      public String[] getPages() {
          try {
  
              counter.await();
          } catch (InterruptedException e) {
              packages=new String[0];
          }
          return packages;
      }
  
      @Override
      public void displayData(ServerOutput output) {
  
  
          Page[] pgArray = new Page[((PageData)output).getPages().size()];
          pages=new String[pgArray.length];
          pgArray = ((PageData)output).getPages().toArray(pgArray);
          for(int i=0;i&lt;pgArray.length;i++){
              pages[i]=pgArray[i].getName();
          }
          counter.countDown();
  
      }
  
  }
  
  
  
  
  
  public class BackgroundDataPopulator extends AsyncTask&lt;Void, String, ServerOutput&gt; {
      // connector=new JSONConnector();
      Connector connector;
      String curUrl;
      ServerOutput curServerOutput;
      ServerDataProcessor processor;
  
  
      public BackgroundDataPopulator(String url, ServerOutput serverOutput,ServerDataProcessor curProcessor) {
          //connector = new UnitTestConnector();
          connector = new JSONConnector();
          curUrl = url;
          curServerOutput = serverOutput;
          processor=curProcessor;
      }
  
      @Override
      protected ServerOutput doInBackground(Void... params) {
  
          return connector.getData(URLUtils.getFormattedUrl(curUrl),curServerOutput);
      }
  
      @Override
      protected void onPostExecute(ServerOutput output) {
          processor.displayData(output);
          //Toast.makeText(BaseFragmentActivity.this, "Done!",Toast.LENGTH_SHORT).show();
      }
  }
  
  
  
  
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      pagePopulator=new PagePopulator();
      pagePopulator.getPagesFromServer();
      super.onCreate(savedInstanceState);
  
  }
  
  public ArrayAdapter&lt;CharSequence&gt; getSpinnerDataArray(String item) {
      return new ArrayAdapter&lt;CharSequence&gt;(this,android.R.layout.simple_spinner_item,pagePopulator.getPages());
  }
  </code></pre>