package com.hava.test;

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

public class Main  {


    public static void main(String[] args) throws IOException, InterruptedException {
        ServerSocket serverSocket = new ServerSocket(8022);
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("Started");
                while (!Thread.currentThread().isInterrupted()) {
                    try {
                        System.out.println("Accept");
                        serverSocket.accept();
                    } catch (IOException e) {
                        System.out.println("Gotcha. Should never occurred");
                        e.printStackTrace();
                    }
                }
            }
        });

        thread.start();
        thread.join();
    }
}
