title: android:ExecutorService:- ExecutorService does not wait for executorService to complete
body: <p>I have an <code>executorService</code> that does not wait for the <code>executorService</code> part to complete and it directly returns the return value without waiting
  below is my code: Please see if I am implementing the <code>executorService</code> properly and help me correct it if required</p>
  
  <pre><code> public boolean validateForm() {
          flag=true;
          executorService = Executors.newSingleThreadExecutor();
              Future f = executorService.submit(new Runnable() {
                  public void run() {
                      Log.e("FLAGssssss", "" + flag);
                      checkSourceCode(new BooleanCallBack() {
                          @Override
                          public void onSuccess(boolean result) {
                              Log.e("RESULT  ISSSSS", "" + result);
                              validateCode = result;
                              Log.e("validateSourceCode  ISSSSS", "" + validateSourceCode(result));
                              if (validateSourceCode(result) == false) {
                                  flag = false;
                              }
                              Log.e("FLAG ISSSSS", "" + flag);
                          }
                      });
                  }
              });
              try {
                  if (f.get() != null) {
                      flag = true;
                  }
                  Log.e("FUTURE IS", "" + f.get());
  
              } catch (InterruptedException e) {
                  e.printStackTrace();
              } catch (ExecutionException e) {
                  e.printStackTrace();
              }
          if (!accept_checkbox.isChecked()) {
              Toast.makeText(getActivity().getBaseContext(), "Accept The Terms &amp; Conditions To Proceed", Toast.LENGTH_LONG).show();
              //        accept_checkbox.requestFocus();
              flag = false;
          }
          if (!validateAddress()) {
              flag = false;
          }
          if (!validatelandmark()) {
              flag = false;
          }
          if (!validateDistrict()) {
              flag = false;
          }
          if (!validatePincode()) {
              flag = false;
          }
          if (!validateFullfillment()) {
              flag = false;
          }
          if (flag) {
              saveData();
          }
  
          executorService.shutdown();
          return flag; //flag is returned even before the executorService above is executed first
      }
  </code></pre>