public void init() { if (serverThread != null) { serverThread.Interrupt(); stub.Dispose(); handler.Dispose(); } stub = new ServerStub(); serverThread = new Thread(ServerStub.Run); serverThread.Start(stub); new Thread(Program.Run).Start(); Thread.Sleep(300); handler = Program.Handler; }