2016-01-20 163 views

回答

0

您可以在線程調用開始時設置一個標誌,並且當用戶單擊該按鈕時將標誌更改爲false。行內有:

private volatile boolean flag; 

    @Override 
    public void run() { 
     this.flag = true; 
     while (this.flag) { 
      try { 
       // mp3 playing code goes here 
      } catch (InterruptedException e) { 
       this.flag = false; 
      } 
     } 
    }