Socket
연결을 기다리는 Runnable
클래스가 있습니다. 연결을 기다리지 않고 루프 밖으로 나올 수있는 JButton
을 추가하고 싶습니다.while 루프에서 연결을 기다리는 동안 Runnable 중지
는 여기에 내가이 문제에 대한보고와 루프를 종료 a solution here을 발견
volatile boolean finished = false;
while (!finished) {
System.out.println("Server Started....");
clientSocket = serverSocket.accept(); // want to skip this line when the button is pressed
if (!clientSocket.isClosed() && ServerSettings.getServerStatus() != -1) {
// start communication
} else {
// close connection
}
}
루프를합니다. 그러나 이것이 내 문제를 완전히 해결하지는 못합니다. 나는 finished
변수의 값을 변경할 수 있지만 새로운 값을 확인하기 위해 대기 변수를 한 번 건너 뛸 필요가 있습니다.
도움이 필요합니다.
제쳐두고 : true &&! finished ==! finished. – Sinkingpoint
@Quirliom : 고맙습니다. 게시물을 업데이트했습니다. –