![JAR search and dependency download from the Maven repository](/logo.png)
link.jfire.socket.socketclient.ChannelGroupSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jfire-socket Show documentation
Show all versions of jfire-socket Show documentation
Jfire - socket is a server-side framework based on AIO. Users only need a simple implementation of a business logic processing interface can be the business data processing. The framework provides the client and server at the same time. Have strong connection capacity. Single server provides tens of thousands of connections.
The newest version!
package link.jfire.socket.socketclient;
import java.io.IOException;
import java.nio.channels.AsynchronousChannelGroup;
import java.util.concurrent.ThreadFactory;
public class ChannelGroupSource
{
private static AsynchronousChannelGroup channelGroup;
static
{
try
{
channelGroup = AsynchronousChannelGroup.withFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2, new ThreadFactory() {
private int i = 1;
public Thread newThread(Runnable r)
{
return new Thread(r, "客户端通信处理线程-" + i++);
}
});
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public static AsynchronousChannelGroup getChannelGroup()
{
return channelGroup;
}
public static void resetThreadNum(int size)
{
AsynchronousChannelGroup tmp = channelGroup;
try
{
AsynchronousChannelGroup newChannelGroup = AsynchronousChannelGroup.withFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2, new ThreadFactory() {
private int i = 1;
public Thread newThread(Runnable r)
{
return new Thread(r, "客户端通信处理线程-" + i++);
}
});
channelGroup = newChannelGroup;
tmp.shutdown();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public static void shutdown()
{
try
{
channelGroup.shutdownNow();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy