title: wait/ resume thread in java android
body: <p>am trying to pause a thread and then resume it but when i do the pause it freeze the application. i try several things but with no luck.
  on my main activity am calling the thread and have the button that will pause the thread  and a second runnable class it start running and draw on my plot which include and the pause function. the code that i implement is the follow</p>
  
  <p><strong>Main activity</strong></p>
  
  <pre><code>            public void onCreate(Bundle savedInstanceState) {
                      super.onCreate(savedInstanceState);
  
           mDoctorDynamicXYDatasource= new DoctorDynamicXYDatasource(this, mHandler);
         findViewById(R.id.Pause).setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View v) { 
                   synchronized(pp){
                      mDoctorDynamicXYDatasource.Pause();
                  Log.i("File", "Pause button ");
                      }
                  }   
      });
      findViewById(R.id.Start).setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) { 
             draw();
           }
      });
  
  
      public void draw(){
  
         ///some code
         pp= new Thread(data);
           pp.start();
      }
  
  and on the **DoctorDynamicXYDatasource class** am doing the follow
  
    public class DoctorDynamicXYDatasource extends Activity implements Runnable {
  
     public void run() {
           //loading and draw on the plot
            }
  
    public void Pause() {
          synchronized (Thread.currentThread()) {
           Log.i("File","pause");
                  try {
                  Thread.currentThread().wait();
              } catch (InterruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
              }
          }
  
      }
  </code></pre>
  
  <p>how can i pause the thread and then start it again. when i pause the thread it lock instead only the draw plot all the screen and the button without be able to make a selection</p>
  
  <p>EDIT</p>
  
  <p>i add the code that you tell me and from the main activity with the pause button am calling the pause fuinction from my DoctorDynamicXYDatasource class but it's not synchronized in order to wait the thread. am also not allow to call the pause function from other class?</p>
  
  <pre><code>mDoctorDynamicXYDatasource= new DoctorDynamicXYDatasource(this, mHandler);
           findViewById(R.id.Pause).setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View v) { 
  
                      Log.i("File", "Pause button pressed");
      mDoctorDynamicXYDatasource.pause();
  
                  }
              });
  </code></pre>