@Override
    public void run() {
        for(Object socket : sockets) {
            if(socket instanceof DatagramSocket)
                if(((DatagramSocket) socket).isClosed()) {
                    ((DatagramSocket) socket).close();
                    continue;
                }

            if(socket instanceof ServerSocket)
                if(((ServerSocket) socket).isClosed()) {
                    try {
                        ((ServerSocket) socket).close();
                    } catch (IOException e) {
                        System.err.println("Can't stop tcp server socket");
                    }
                    continue;
                }

            if(socket instanceof Socket)
                if(((Socket) socket).isClosed()) {
                    try {
                        ((Socket) socket).close();
                    } catch (IOException e) {
                        System.err.println("Can't stop tcp socket");
                    }
                    continue;
                }
        }
    }