package org.hello2;
import java.util.Date;
public class TestService {
private static Thread thread = null;
private static Service service = null;
public static void stopService(String[] args){
service.setServiceStatu(false);
}
public static void startService(String[] args){
service = new Service();
thread = new Thread(service);
try{
// 将服务线程设定为用户线程
thread.setDaemon(false);
if(!thread.isDaemon()){
System.out.println("[" + new Date() + "]成功设定为用户线程!");
}
thread.start();
}catch(SecurityException e){
e.printStackTrace();
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String [] args){
startService(args);
}
}