⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readerthread.java

📁 piweurrrrq i o fhsadhfka fd dskajc zxkjcnkjsahc
💻 JAVA
字号:
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.chat.server.remote;import java.io.InputStream;import java.io.InputStreamReader;import java.io.BufferedReader;import java.io.IOException;import com.lyrisoft.chat.IConnectionListener;/** * Constantly reads from the BufferedReader. * Notifies the ChatServerLocal via the incomingMessage() method */public class ReaderThread extends Thread {    protected IConnectionListener _connectionListener;    protected BufferedReader _in;    protected InputStream _inputStream;    protected boolean _keepGoing = true;    protected ConnectionHandler _connectionHandler;        ReaderThread(ConnectionHandler handler, IConnectionListener listener, InputStream in) {        super("ReaderThread");        _connectionHandler = handler;        _connectionListener = listener;        _inputStream = in;        _in = new BufferedReader(new InputStreamReader(in));    }        public void normalRun() {        try {            String newLine;            while (_keepGoing &&                   (newLine = _in.readLine()) != null)            {                _connectionListener.incomingMessage(newLine);                ChatServer.DEBUG("> " + newLine);            }        }        catch (IOException e) {            ChatServer.log(e);        }    }        public void bsdHackRun() {        try {            String newLine;            while (_keepGoing) {                try {                    while (_inputStream.available() < 1) {                        Thread.sleep(25);                    }                }                catch (InterruptedException e) {}                newLine = _in.readLine();                _connectionListener.incomingMessage(newLine);                ChatServer.DEBUG("> " + newLine);            }        }        catch (IOException e) {            ChatServer.log(e);        }    }        public void run() {        String s = System.getProperty("BSD_HACK");        if (s == null) {            normalRun();        } else {            bsdHackRun();        }        _connectionHandler.shutdown(true);    }        void pleaseStop() {        _keepGoing = false;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -