Engineering/JAVA Thread 종료시키기. by 알 수 없는 사용자 2008. 2. 4. 이렇게 해도 되는 것인지 모르겠다. -_-public class RecvThread implements Runnable { public void run() { try { byte[] reqCode = new byte[1]; while (!Thread.currentThread().isInterrupted()) { is.read(reqCode); switch (reqCode[0]) { case Protocol.RESPONSE_LOGIN: loginHandler(); break; case Protocol.RESPONSE_SLOGIN: sLoginHandler(); break; case Protocol.RESPONSE_JOIN: joinHandler(); break; case Protocol.RESPONSE_DATA: dataHandler(); break; case Protocol.RESPONSE_DIRENTRY: dirHandler(); break; } } } catch (Exception e) { Log.e(TAG_RECEIVE, TAG_RECEIVE + e.getMessage()); } } } public void connect() { try { socket = new Socket(serverIp, portNum); is = new BufferedInputStream(socket.getInputStream()); os = new BufferedOutputStream(socket.getOutputStream()); recvThread = new Thread(new RecvThread()); recvThread.start(); } catch (Exception e) { Log.e(TAG_CONNECTION, TAG_CONNECTION + e.getMessage()); } } public void disconnect() { try { recvThread.interrupt(); is.close(); os.close(); socket.close(); } catch (Exception e) { Log.e(TAG_CONNECTION, TAG_CONNECTION + e.getMessage()); } } 공유하기 게시글 관리 Humaneer.net 관련글 [펌]about String, StringBuilder, StringBuffer Java에서 Pattern, Matcher로 원하는 것만 뽑아내기. Stopping thread in Java