package test;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;

public class AcceptThread extends Thread{
	private ServerSocket ssocket;
	private boolean running = false;
	public AcceptThread(ServerSocket ss){
		ssocket = ss;
	}
	public void stopByInterrupt(){
		running = false;
		this.interrupt();
	}
	public void stopByClosingSocket(){
		running = false;
		try{
			ssocket.close();
		}catch(IOException e){}
	}
	public void run() {
		// TODO Auto-generated method stub
		running = true;
		System.out.println("Thread started");
		while (running){
			/*
			try{
			Socket s = ssocket.accept();
			}catch(SocketException e){
				e.printStackTrace();
				running = false;
			}catch(IOException ioe){
				ioe.printStackTrace();
				running = false;
			}*/
		}
		System.out.println("thread is stopped");
	}

}
