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

📄 mice.java

📁 实现简单的远程监控
💻 JAVA
字号:
package com.cheng;

import java.io.*;
import java.net.*;
import java.awt.*;
import javax.swing.*;
import java.awt.image.BufferedImage;

public class Mice implements Runnable {
    private ServerSocket server;
    private BufferedImage image;
    private DataInputStream in;
    private Thread t = null;
    private ImageIcon icon;
    private final int []PORT ={1978,2006,4000,8000};
    private static int portIndex=0;
    private static Mice mice;

    private Mice() {
       t=new Thread(this);
       t.start();
    }

    //返回唯一实例
    public static Mice getInstance() {
        return ((null == mice) ? mice=new Mice() : null);
    }

    public void run() {
        try {
            server = new ServerSocket(PORT[portIndex]);
            while (true) {
                Socket socket = server.accept();
                if (false == ThreadInfo.SendIsLive) {
                    new SendThread(socket).start();
                }
                if (false == ThreadInfo.CoopIsLive) {
                    new Coop(socket).start();
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            try {
                portIndex++;
                if(portIndex>3)
                    portIndex=0;
                server.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }

    }

    /***
     * Main方法
     */
    public static void main(String args[]) {
        try
        {
            Mice m=Mice.getInstance();
        }
        catch(Exception ee)
        {
        }
    }

}

⌨️ 快捷键说明

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