Constructor block Server, potentially undefined, c accept().
Two things about Swing programs:
- Never do a long task in a Swing event stream and
- Swing Swing, .
, Swing, , , , Server. , Swing .
, , ? , Thread.start(), run(), , " " .
:
- ,
Thread.sleep(0); run(). . CPU, -op, . - ,
isConnected volatile - , , , . isConnected false, , run() , JVM RuntimeException.- Threads . (. Java Concurrency .)
accept ServerSocket, Thread run()! !- :
:
thread = new Thread(this);
thread.setDaemon(true);
thread.run(), not, Thread! Thread.start(). Thread ( № 3 ) , . , IOExceptions , . , isConnected false IOException, closeConnection().