mengine.java
来自「httptunnel.jar httptunnel java 源码」· Java 代码 · 共 67 行
JAVA
67 行
package net.jumperz.app.MDoorman;
import net.jumperz.util.*;
import net.jumperz.net.*;
import java.io.*;
import java.util.*;
public class MEngine
{
private static final int THREAD_COUNT = 30;
private static MEngine instance = new MEngine();
private boolean run = false;
private MMultiAcceptor multiAcceptor;
private MThreadPool threadPool;
// --------------------------------------------------------------------------------
private MEngine()
{
}
// --------------------------------------------------------------------------------
public static MEngine getInstance()
{
return instance;
}
// --------------------------------------------------------------------------------
public boolean isRun()
{
return run;
}
// --------------------------------------------------------------------------------
public synchronized void start( String host, int port )
{
if( run )
{
return;
}
run = true;
if( threadPool == null )
{
threadPool = new MThreadPool( THREAD_COUNT );
MSession.threadPool = threadPool;
}
multiAcceptor = new MMultiAcceptor( host, port );
MAcceptorObserver observer = new MAcceptorObserver( multiAcceptor, threadPool );
multiAcceptor.register1( observer );
threadPool.addCommand( multiAcceptor );
}
// --------------------------------------------------------------------------------
public void setThreadPool( MThreadPool threadPool )
{
this.threadPool = threadPool;
MSession.threadPool = threadPool;
}
// --------------------------------------------------------------------------------
public MThreadPool getThreadPool()
{
return threadPool;
}
// --------------------------------------------------------------------------------
public synchronized void stop()
{
run = false;
multiAcceptor.breakCommand();
}
// --------------------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?