张世豪
昨天 ef78717c5b956a26b360de44f774fc2b804296c2
src/chushihua/lunxunzaixian.java
@@ -56,7 +56,7 @@
            onlinePollingThread = new Thread(new OnlinePollingTask(), "Online-Polling-Thread");
            onlinePollingThread.setDaemon(true);
            onlinePollingThread.start();
            System.out.println("在线轮询已启动,周期间隔: " + cycleInterval + "ms, 卡槽间隔: " + slotInterval + "ms");
            //System.out.println("在线轮询已启动,周期间隔: " + cycleInterval + "ms, 卡槽间隔: " + slotInterval + "ms");
            return true;
        } catch (Exception e) {
            System.err.println("启动在线轮询线程时发生异常: " + e.getMessage());
@@ -72,7 +72,7 @@
     */
    public static boolean stopOnlinePolling() {
        if (!isRunning.get()) {
            System.out.println("在线轮询未在运行");
            //System.out.println("在线轮询未在运行");
            return false;
        }
        
@@ -101,7 +101,7 @@
        }
        
        shouldStop.set(false);
        System.out.println("在线轮询已停止");
        //System.out.println("在线轮询已停止");
        return true;
    }
    
@@ -111,17 +111,17 @@
     */
    public static boolean pauseOnlinePolling() {
        if (!isRunning.get()) {
            System.out.println("在线轮询未在运行,无法暂停");
            //System.out.println("在线轮询未在运行,无法暂停");
            return false;
        }
        
        if (isPaused.get()) {
            System.out.println("在线轮询已经处于暂停状态");
            //System.out.println("在线轮询已经处于暂停状态");
            return false;
        }
        
        isPaused.set(true);
        System.out.println("在线轮询已暂停");
        //System.out.println("在线轮询已暂停");
        return true;
    }
    
@@ -131,12 +131,12 @@
     */
    public static boolean resumeOnlinePolling() {
        if (!isRunning.get()) {
            System.out.println("在线轮询未在运行,无法恢复");
            //System.out.println("在线轮询未在运行,无法恢复");
            return false;
        }
        
        if (!isPaused.get()) {
            System.out.println("在线轮询未处于暂停状态");
            //System.out.println("在线轮询未处于暂停状态");
            return false;
        }
        
@@ -150,7 +150,7 @@
        synchronized (lunxunzaixian.class) {
            lunxunzaixian.class.notifyAll(); // 唤醒等待的线程
        }
        System.out.println("在线轮询已恢复");
        //System.out.println("在线轮询已恢复");
        return true;
    }
    
@@ -195,7 +195,7 @@
    public static void setPollingIntervals(int cycleMs, int slotMs) {
        cycleInterval = Math.max(cycleMs, 1000); // 最小1秒
        slotInterval = Math.max(slotMs, 50);     // 最小50毫秒
        System.out.println("在线轮询间隔已设置 - 周期间隔: " + cycleInterval + "ms, 卡槽间隔: " + slotInterval + "ms");
        //System.out.println("在线轮询间隔已设置 - 周期间隔: " + cycleInterval + "ms, 卡槽间隔: " + slotInterval + "ms");
        
        // 如果正在运行,重新启动以应用新的间隔
        if (isRunning.get()) {
@@ -275,7 +275,7 @@
    private static class OnlinePollingTask implements Runnable {
        @Override
        public void run() {
            System.out.println("在线轮询线程开始运行");
            //System.out.println("在线轮询线程开始运行");
            
            while (isRunning.get() && !Thread.currentThread().isInterrupted() && !shouldStop.get()) {
                try {
@@ -311,7 +311,7 @@
                    Thread.sleep(cycleInterval);
                    
                } catch (InterruptedException e) {
                    System.out.println("在线轮询线程被中断");
                    //System.out.println("在线轮询线程被中断");
                    Thread.currentThread().interrupt();
                    break;
                } catch (Exception e) {
@@ -328,7 +328,7 @@
                }
            }
            
            System.out.println("在线轮询线程结束运行");
            //System.out.println("在线轮询线程结束运行");
        }
        
        /**
@@ -357,7 +357,7 @@
            
            if (cardSlots.isEmpty()) {
                if (lunxun.DEBUG_ENABLED) {
                    System.out.println("没有找到有卡的卡槽");
                    //System.out.println("没有找到有卡的卡槽");
                }
                return true;
            }
@@ -393,7 +393,7 @@
            }
            
            if (polledCount > 0 && lunxun.DEBUG_ENABLED) {
                System.out.println("在线轮询完成,成功查询 " + polledCount + "/" + totalCardSlots + " 个有卡卡槽");
                //System.out.println("在线轮询完成,成功查询 " + polledCount + "/" + totalCardSlots + " 个有卡卡槽");
            }
            
            return polledCount > 0;
@@ -412,7 +412,7 @@
                if (result) {
                    // 记录调试信息(减少输出频率)
                    if (lunxun.DEBUG_ENABLED && (slotNumber == 1 || slotNumber % 10 == 0)) {
                        System.out.println("在线轮询 - 查询有卡卡槽 " + slotNumber);
                        //System.out.println("在线轮询 - 查询有卡卡槽 " + slotNumber);
                    }
                    return true;
                } else {
@@ -442,7 +442,7 @@
            return 0;
        }
        
        System.out.println("开始立即轮询有卡卡槽...");
        //System.out.println("开始立即轮询有卡卡槽...");
        
        OnlinePollingTask task = new OnlinePollingTask();
        
@@ -471,7 +471,7 @@
     */
    public static boolean setOnlinePollingPaused(boolean paused) {
        if (!isRunning.get()) {
            System.out.println("在线轮询未在运行,无法设置暂停状态");
            //System.out.println("在线轮询未在运行,无法设置暂停状态");
            return false;
        }