private void startSocketThread() { Ctrl.print("启动socket线程"); if (ShineSetting.useKCP) { _kcpThread = new BaseThread("kcpThread"); _kcpThread.setRunCall(kcpLoop); ThreadControl.addThread(_kcpThread); _kcpThread.start(); } if (ShineSetting.socketUseAsync) { return; } _sendThread = new BaseThread("ioSendThread"); _sendThread.setRunCall(sendLoop); ThreadControl.addThread(_sendThread); _receiveThread = new BaseThread("ioReceiveThread"); _receiveThread.setRunCall(receiveLoop); _receiveThread.setSleepTime(1); ThreadControl.addThread(_receiveThread); _sendThread.start(); _receiveThread.start(); }
/** 析构 */ public void dispose() { closeAndClear(); _disposed = true; if (ShineSetting.useKCP) { if (_kcpThread != null) { _kcpThread.exit(); ThreadControl.removeThread(_kcpThread); _kcpThread = null; } } if (!ShineSetting.socketUseAsync) { if (_sendThread != null) { _sendThread.exit(); ThreadControl.removeThread(_sendThread); _sendThread = null; } if (_receiveThread != null) { _receiveThread.exit(); ThreadControl.removeThread(_receiveThread); _receiveThread = null; } } }
/** 初始化 */ public static void init() { _mainThread = Thread.CurrentThread; _assistThread = new BaseThread("assistThread"); _assistThread.start(); addThread(_assistThread); _ioThread = new BaseThread("ioThread"); _ioThread.start(); addThread(_ioThread); }
public static void removeThread(BaseThread thread) { _threadList.removeObj(thread); }
public static void addThread(BaseThread thread) { _threadList.add(thread); }