📄 mengine.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -