public static void main(String[] args) {
Server s = new Server();
s.start();
s.end();
}
}
public class Server {
private Thread thread;
public void start(){
MyThread myThread = new MyThread();
thread = new Thread(myThread);
thread.setDaemon(true);
thread.start();
}
public void end(){
thread.interrupt();
}
private class MyThread implements Runnable{
public void run(){
int i = 0;
while(true){
System.out.println(i++);
}
}
}
}