Restlet设置最大线程数

如下代码可以设置Restlet的最大线程数:

    public static void main(String[] args) throws Exception
    {
        Component component = new Component();
        Context context = new Context(); 
        context.getParameters().set("maxThreads", "100"); 
        context.getParameters().set("maxConnectionsPerHost", "100"); 
        context.getParameters().set("maxTotalConnections", "100"); 
        Server server = new Server(context, Protocol.HTTP, 8181); 
        component.getServers().add(server); 
        component.getDefaultHost().attach(new Application(){
            @Override
            public Restlet createInboundRoot() {
                Router router = new Router(getContext());
                router.attach("/xxx",XXXXX.class);
                return router;
            }
        });
        component.start();
    }

 

你可能感兴趣的:(代码琐记)