先贴代码
主类
package com.alarm;import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class SocketListener implements Runnable{
private ServerSocket ser;
private String port;
public SocketListener(){
try {
ser=new ServerSocket(8888);
} catch (IOException e) {

}

new Thread(this).start();
}
public void run() {
try {
while(true){
new Connection(ser.accept());
}
} catch (Exception e) {
System.out.println("***"+e.getMessage());

}


}
public static void main(String[] arg){
SocketListener socketlistener=new SocketListener();
Alarmlistener   a=new Alarmlistener();

  }}
class Connection extends Thread{
private Socket s;
private BufferedReader br;
private String msg;
public Connection(Socket s){
this.s=s;
this.start();
}
public void run(){
try {
br = new BufferedReader(new InputStreamReader(s   
                    .getInputStream()));  
while((msg=br.readLine())!=null){
if(msg.trim().equals("updata")){
System.out.println("收到更新命令");
br.close();


//System.out.println("socketListener===="+FindAlarmtask.getInstance().getVectorAlarmBean().size());
break;
}
}
} catch (Exception e) {
// TODO: handle exception
}
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
线程
package com.alarm;import java.util.Timer;public class Alarmlistener implements Runnable {
private Timer timer;
private Alarmlistener al;
private boolean isup;
public boolean isIsup() {
return isup;
}
public void setIsup(boolean isup) {
this.isup = isup;
}
public Alarmlistener(){
timer=new Timer();
    new Thread(this).start();
}
public void run() {

isup=true;
while(isup){
try {

} catch (Exception e) {
}
}
}
public synchronized void shutDown() {
isup = false ;
    }
    public synchronized boolean isShutDown() {
        return isup;
    }
}
程序如上,现在在socket接到一个请求后,要停止Alarmlistener进程,socket接受时在内部来里面的。如何在收到“更新命令”时,让Alarmlistener 线程停止,顺便问下能否在收到另外一种情况的时候,让这个线程又重新启动。能否做到这样的,在这先谢过了。