怎么改才能结束线程(代码如下)!
这是一个类里面的三个方法!
stop()不能用;
public void play(){
if(BasicPlayer.isStop&&BasicPlayer.isActive){
basicPlayer=new BasicPlayer(soundFile);
thread=new Thread(basicPlayer);
thread.start();
}else if(!BasicPlayer.isStop&&!BasicPlayer.isActive) {
BasicPlayer.isActive=true;
}
}
//暂停
public void pause(){
if(!BasicPlayer.isStop&&BasicPlayer.isActive){
BasicPlayer.isActive=false;
}
}
//停止
public void Stop(){
if(!BasicPlayer.isStop){
thread.stop();
BasicPlayer.isStop=true;
return;
}
}
------解决方案--------------------thread.interrupt()
------解决方案--------------------是不是你的basicPlayer.run方法中还有线程?